Page 1 of 1

Setting paper source properties

PostPosted: Fri Jun 14, 2013 5:59 am
by jallen
Hi Jason,

I have a need to set the "first page, all other pages" paper source properties in docx4j. I did some searching but didn't come up with much. Can you point me in the right direction on how to best do this?

Thanks,
Jeff

Re: Setting paper source properties

PostPosted: Mon Jun 17, 2013 8:48 pm
by jason
Hi Jeff

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
import java.math.BigInteger;
import org.docx4j.wml.CTPaperSource;
import org.docx4j.wml.SectPr;

:

org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();

SectPr sectpr = wmlObjectFactory.createSectPr();

    // Create object for paperSrc
    CTPaperSource papersource = wmlObjectFactory.createCTPaperSource();
    sectpr.setPaperSrc(papersource);
        papersource.setOther( BigInteger.valueOf( 4) );
        papersource.setFirst( BigInteger.valueOf( 1) );

 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


or

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
String openXML = "<w:sectPr xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">"
            + "<w:paperSrc w:first=\"1\" w:other=\"4\"/>"
        +"</w:sectPr>";
SectPr sectpr = (SectPr)XmlUtils.unmarshalString(openXML);
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


See http://webapp.docx4java.org/OnlineDemo/ ... erSrc.html

cheers .. Jason

Re: Setting paper source properties

PostPosted: Wed Jun 19, 2013 11:11 pm
by jallen
I got it working. Thanks for the help!