Page 1 of 1

Footer, hardcoded height?

PostPosted: Fri Mar 08, 2013 2:10 am
by niol1000
Hi All,

Using docx4j 2.8.1 and latest nightly

When we try to convert a docx document to PDF that has a bigger than normal footer (we add a quite large image in the footer) then the footer get "cut off". It seems like that the PDF conversion never change the size of the footer(only render the default size). We do the conversion in the simplest possible way:

WordprocessingMLPackage wp2 = WordprocessingMLPackage.load(new File("c:/testing23.docx"));
PdfConversion c = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(wp2);

FileOutputStream fos = null;

try {
fos = new FileOutputStream(new File("c:/testing.pdf"));
c.output(fos, null);

} catch(Exception e) {e.printStacktrace();}

Is there anyway we can make the PDF conversion output the actual footer size?

Regards
Niklas Olofsson

Re: Footer, hardcoded height?

PostPosted: Fri Mar 08, 2013 5:06 am
by jason
There is room for improvement here.

The relevant code is in https://github.com/plutext/docx4j/blob/ ... ilder.java
line 190 onwards.

There is a bit of developer level documentation about how it works. See https://github.com/plutext/docx4j/blob/ ... oters.docx and https://github.com/plutext/docx4j/blob/ ... t_Out.docx

Re: Footer, hardcoded height?

PostPosted: Tue Mar 12, 2013 6:52 pm
by niol1000
This seems not be an easy problem to resolve, I can't find anywhere in document where the size of the footer is defined. So we need to calculate the height of the footer based on the content and I haven't had time yet to figure out a solution to do that in a good way.

But we have done a workaround that solves our problem. We know the size of the image we need to place in the footer so we simply change the footer size by calling:

wp,getDocumentModel().getSections().get(0).getPageDimensions().setFooterExtent(IMAGE_HEIGHT).

Maybe this information can help somebody.

Best regards
Niklas