Page 1 of 1

Page orienation and line breaks for docx output?

PostPosted: Mon Sep 19, 2011 10:39 am
by matthewy
Hey guys,

Writing a small program to convert reports from an iSeries, into word docs, and had some success, which is great. It is being written in RPG, but invoking some java classes that have just wrapped up for convenience, some docx4J methods.

I have hit two issues. I am having some trouble identifying how to put a page into landscape oritenation for docx output? STPageOrientation seemed a good place to start, but that seems to be designed to retrieve the value, not set it. Does anyone have some sample code that would point me in the right direction?

The second issue is when I mix between text wrapping breaks and page breaks, I lose the page breaks - doesn't even output them in the XML. Any clues as to what I have done?

Code: Select all
org.docx4j.wml.Br lineBr = factory.createBr();
lineBr.setType(STBrType.TEXT_WRAPPING);
org.docx4j.wml.Br pageBr = factory.createBr();
pageBr.setType(STBrType.TEXT_WRAPPING);
...
run.getContent().add(lineBr);
...
run.getContent().add(pageBr);


The line breaks come out ok, but not the page ones. If I don;t use the line breaks, page breaks work well too. :?:

Regards

Re: Page orienation and line breaks for docx output?

PostPosted: Mon Sep 19, 2011 2:58 pm
by matthewy
OK, so the landscape mode issue is soprt of resolved - the build 2.7.1 has it managed in a proeprties file - brilliant.

But now I am getting a Class not found error
java.lang.NoClassDefFoundError: org.docx4j.openpackaging.packages.OpcPackage


Any thoughts?

Still no luck on the breaks issue

Re: Page orienation and line breaks for docx output?

PostPosted: Tue Sep 20, 2011 10:20 pm
by jason
Maybe I'm misunderstanding, but in your code sample,

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
org.docx4j.wml.Br lineBr = factory.createBr();
lineBr.setType(STBrType.TEXT_WRAPPING);
org.docx4j.wml.Br pageBr = factory.createBr();
pageBr.setType(STBrType.TEXT_WRAPPING);
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


your pageBr object looks like a line break? Try the "page" value for the enumeration.

Re: Page orienation and line breaks for docx output?

PostPosted: Thu Sep 22, 2011 10:15 am
by matthewy
Yeah apologies, that was poor copying of the code. The original source wasn't making that mistake, but I was having difficulties getting my head around runs vs paragraphs. Resolved it eventually though.

Thanks