Is there any best way to check the no of pages in docx ?
Is there any way to limit the no of pages to some numbers while adding contents programmatically in docx ? (Reaching the limit we have to throw an exception.)
Is there any best way to check the no of pages in docx ?
Hi Sharon,
Document doc = new Document(“c:\temp\in.docx”);
DocumentBuilder builder = new DocumentBuilder(doc);builder.writeln(“add some content”);
// Insert a PAGE field and update it.
Field page = builder.insertField(“PAGE”);
builder.getDocument().updatePageLayout();
page.update();// Determine the current Page Number
int pageNumber = Integer.parseInt(page.getResult());// Remove PAGE field.
page.remove();doc.save(“c:\temp\out.docx”);