Page 1 of 1

Landscape page orientation

PostPosted: Sat Sep 01, 2012 12:00 am
by meraman119
Hi,

How to create landscape oriented page in docx file.

I have inserted below code before creating WML package -

Code: Select all
        Properties properties = Docx4jProperties.getProperties();
        properties.setProperty("docx4j.PageOrientationLandscape", "true");

But its not working.

Can anyone please help me?

Thanks

Re: Landscape page orientation

PostPosted: Sat Sep 01, 2012 12:46 am
by meraman119
I myself found solution by adding section properties in body at end, something like -

Code: Select all
            SectPr sectPr = (SectPr)XmlUtils.unmarshalString("<w:sectPr xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">"
                    + "<w:pgSz w:w=\"16839\" w:h=\"11907\" w:orient=\"landscape\"/>"
                    + "</w:sectPr>");

            body.getContent().add(sectPr);


For those who want to have landscape orientation in page, you can add above SectPr after adding all paragraphs or tables, i.e. in end body place section properties which specifies page size and orientation.

Thanks

Re: Landscape page orientation

PostPosted: Sat Sep 01, 2012 8:22 am
by jason
or use:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
public static WordprocessingMLPackage createPackage(PageSizePaper sz, boolean landscape )
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4