Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JWord
>
Tutorial
> Page Break
The following example shows you how to set page break.
import com.independentsoft.office.ExtendedBoolean; import com.independentsoft.office.word.Paragraph; import com.independentsoft.office.word.Run; import com.independentsoft.office.word.WordDocument; public class Example { public static void main(String[] args) { try { WordDocument doc = new WordDocument(); Run run1 = new Run(); run1.addText("Some text on the first page."); Paragraph paragraph1 = new Paragraph(); paragraph1.add(run1); Run run2 = new Run(); run2.addText("Some text on the second page."); Paragraph paragraph2 = new Paragraph(); paragraph2.add(run2); paragraph2.setPageBreakBefore(ExtendedBoolean.TRUE); doc.getBody().add(paragraph1); //on the first page doc.getBody().add(paragraph2); //on the second page doc.save("c:\\test\\output.docx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*