Page 1 of 1

Formatting errors when converting Table.docx to PDF

PostPosted: Wed Nov 26, 2008 5:22 am
by mbmbmb
Hi there -

I've just started playing with docx4j since I'm thinking of using it on a project we are working on.

I tried out the samples.CreatePdf.java class using the sample-docs/Table.docx file as test input (since it looks uncannily like the file we need to convert to pdf).

The resulting pdf document looks ok - but the major problem seems to be the text

<![if
!supportMisalignedColumns]>
<![endif]>


appearing just below the table.

There is also some slight spacing differences and the PDF is missing the heading underline that is in the Table.docx

Does anyone experience a similar result? Or am I using the library incorrectly?

Unfortunately I cannot attach the generated doc as the pdf file extension is not allowed.

Thanks -

Re: Formatting errors when converting Table.docx to PDF

PostPosted: Wed Nov 26, 2008 12:09 pm
by jason
Thanks for picking that up.

That's the HTML transform (which comes from the OpenXMLViewer project) inserting these so called conditional comments, and FlyingSaucer PDF Renderer then rendering it.

A temp workaround is to comment out the two lines in DocX2Html.xslt (lines 6084 and 6093).

Ultimately, either the transform has to have a way of not producing conditional comments, or PDF Renderer needs to be patched to handle them.

See http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx regarding conditional comments.

hope this helps,

Jason

Re: Formatting errors when converting Table.docx to PDF

PostPosted: Mon Jan 19, 2009 12:15 pm
by jason
SVN code as of today defaults to leaving out the 3 conditional comments which are present in the XSLT.