In your code snippet, you are using Aspose.Words. Can you please share how you noticed that the issue is related to Aspose.PDF? Can you please share the related code snippet for our reference as well to show us how you are processing page numbers? We will further proceed to assist you accordingly.
This is not the input file but it is an intermediate file generated by the process, I have saved in the docx format and sending it to you for your reference.
@manasag Thank you for additional information. As I can see the document is generated using old 16.11 version and it looks improperly in MS Word. There are problems with table layout and MS Word shows 138 pages in the document instead of 49 as expected. Could you please make sure you have attached the correct document.
in the new version of Aspose 23.9 jars the method cloneDoc.updateTableLayout(); is being deprecated so could you let me know what was the equivalent method to this that will work in latest versions of Aspose jars
@manasagUpdateTableLayout method was the first attempt of table grid calculation algorithm implementation. Currently another implementation is used internally by Aspose.Words, so normally there is no need to call additional methods to calculate table layout. So there is no equivalent of this method in the public API and it is not required.
it is generated in both the version and in both the versions 16.11 and 23.9 while saving in docx format it is giving is 138 pages but when we try saving in PDF it is giving 49 pages.
Here I’ve attached the template screen shot since the template is in .dot format and I was not able to upload it here, so attached the screen shots of the template and code snippet and the generated PDF
@manasag Unfortunately, the attached document is damaged, so I cannot test the scenario with it. Could you please zip and attached it again? Please zip it, not simply change the file extension.
public void writePagniation(com.aspose.words.Document document)throws Exception{
try{
com.aspose.words.DocumentBuilder builder = new
com.aspose.words.DocumentBuilder(document);
//document.save("C:/Users/c8d2k2/Desktop/Test_file/beforepagination.pdf", SaveFormat.PDF);
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
Font font = builder.getFont();
font.setSize(10);
font.setName("Times New Roman");
builder.setBold(true);
builder.moveToParagraph(2, 0);
builder.writeln();
builder.write("Page"+Constants.SPACE_IN_UNICODE);
builder.insertField("PAGE", null);
builder.write(" of ");
LOGGER.info("logger2");
builder.insertField("SECTIONPAGES", null);
builder.getCurrentParagraph().getParagraphFormat()
.setAlignment(ParagraphAlignment.CENTER);
builder.setBold(false);
document.save("C:/Users/c8d2k2/Desktop/Test_file/sample.docx", SaveFormat.DOCX);
}catch(Exception ps){
LOGGER.error("error in pdf pagniation"+ps);
throw new PrintServerPdfServiceException("error in pdf pagniation"+ps.getMessage());
}
}
This was the method we are using to count the page numbers and here I am attaching the intermediate docx format and pdf format files generated using this method and also the final pdf but we were seeing the paging issue in the final pdf sample.docx (103.9 KB)
@manasag Thank you for additional information. But as I have mentioned the input document you have shared earlier is damaged and cannot be processed on my side. So I cannot test the scenario. Could you please sip and attach the input document again or better create a simple console application that will allow us to reproduce the problem on our side?
Simple conversion of intermediate DOCX document to PDF does not allow to reproduce the problem.