Page 1 of 1

empty images (0kb) when exporting docx to html

PostPosted: Fri Nov 14, 2008 1:57 pm
by Sverre
Hi

After doing a successful convertion of .docx-files to html using docxj4 2.1.0 i observe that the images are created in the specified image directory, but the images are empty (0 bytes).
This is the case for both jpeg and gif images.

I have tried to investigate html generation options, but could not find anything there that i could match to this problem.

Sample code (not actual code, but the essence):
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load("x:\y.docx");
wordMLPackage.setContentType(new ContentType(ContentTypes.WORDPROCESSINGML_DOCUMENT));
OutputStream os = new java.io.FileOutputStream("x:\y.html");
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(os);
HtmlExporter.html(wordMLPackage, result,"x:\y_files");

So, the image directory is created if it does not exist, and the images (1 jpg and 1 gif in y.docx) are created (but empty).

I do get some nullpointerexceptions when the .html function executes, but they don't really tell me anything (they are handled within the HtmlExporter.html() function).
If helpful: the pdf generated in a similar way does not contain the images either...

Any idea where to go from here?

Thanks
Sverre

Some info:
I am using Rational Application Developer 7.0.0.7 and doing a test implementation of docx4j (proof of concept).
My project has lotsa imported .jar-files, but i have finally gotten all jars to match with docx4j 2.1.0 (or so it seems).

My web application is defined for jdk 1.5, and the idea of using docx4j is to generate .pdf and html content (stored in the applications db) of .docx files uploaded to the server.

Re: empty images (0kb) when exporting docx to html

PostPosted: Fri Nov 14, 2008 11:07 pm
by jason
Hi

I just tested using /trac/docx4j/browser/trunk/docx4j/sample-docs/Images.docx (just committed), which contains 1 x JPEG and 1 x PNG image.

I opened the document with docx4all, on Windows and Linux, and created HTML and PDF output.

Of these 4, 3 worked out of the box for me and 1 didn't. The one which didn't work was PDF output on Windows (for PDF output on Windows, iText needs the HTML img@src to start with "file:///" ). I'll fix this in SVN later today.

But that's a different problem to your 0 byte files. Can you post a sample docx exhibiting the problem?

Jason

Re: empty images (0kb) when exporting docx to html

PostPosted: Sat Nov 15, 2008 1:46 am
by jason
Ok, SVN now contains http://dev.plutext.org/trac/docx4j/changeset/584.

But that won't fix your problem.

The behaviour you have observed might happen if your images are external, but in the rels part don't have @TargetMode="External". Are your images external to the docx package?

Re: empty images (0kb) when exporting docx to html

PostPosted: Wed Mar 18, 2009 8:19 am
by Mesni
hello,
I had the same problem. The problem was the older versions of the office ( 2003 ) even with the patch to open and create docx files didn't work. Installing the new office 2007 fixed the problem.

lp, Mesni