Page 1 of 1

CTAltChunk and PDF conversion Problem

PostPosted: Wed Sep 04, 2013 3:58 am
by RayCast
Hello everybody

Please excuse me for my poor english.

I'm creating an application that get an HTML Table and then generate a Word Document.
The problem is that I need to convert the created document into PDF format, and when a try to do this, the result PDF file have the next content:

NOT IMPLEMENTED: support for w:altChunk -

But, in the generated Word Document the table appears OK.

Here is my code:
...
//html is an StringBuffer that contains de HTML code of a Table
CTAltChunk ac = DocumentsFactory.getHTMLTextToDocx(html.toString(), wordMLPackage.getMainDocumentPart(), afiPartId);
wordMLPackage.getMainDocumentPart().addObject(ac);
wordMLPackage.getContentTypeManager().addDefaultContentType("html", "text/html");
wordMLPackage.save(new File("E:\\test.docx"));

InputStream is = new FileInputStream(new File("E:\\test.docx"));
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
PdfSettings pdfSettings = new PdfSettings();

OutputStream out = new FileOutputStream(new File("E:\\test.pdf"));
PdfConversion converter = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(wordMLPackage);
converter.output(out, pdfSettings);
...

Thanks in advance or your help\
Regards, RayCast

Re: CTAltChunk and PDF conversion Problem

PostPosted: Wed Sep 04, 2013 8:47 pm
by jason
You need to ask docx4j to convert the altChunk's HTML content to 'real' WordML, before you do the PDF conversion.

For currently nightly, see the convertAltChunks() method in https://github.com/plutext/docx4j/blob/ ... kHost.java

Things were a little different in 2.8.1; for that, see same method in https://github.com/plutext/docx4j/blob/ ... Aware.java

Re: CTAltChunk and PDF conversion Problem

PostPosted: Thu Sep 05, 2013 1:15 am
by RayCast
Hi jason

Thanks for your quick reply.

I did what you advised to me, but when executed the method convertAltChunks (), in the log I see the following warning: "Skipping altChunk of type HTML".

There is a way to convert HTML AltChunk Types to WordML?
The AltChunkTypes has to be obligatorily XHTML?

Thanks in advance!!!

Regards, RayCast

Re: CTAltChunk and PDF conversion Problem

PostPosted: Thu Sep 05, 2013 6:43 am
by RayCast
Hello again Jason

I'm nearly to make the AltChunk convertion ok.
I converted the HTML content to XHTML format, and the convertAltChunks() method works fine, but some content format was lost, like character colors and Table borders.
So I did the next test. I taked the result XHTML code and created an static .HTML file, and the content format was kept, but for some reason in the result Word Document the format is lost.

Thanks in advance for any help!!!


Regards, RayCast