Aspose PDF jar section pages issue

2138255-PID_DYNAMIC_FAX_TEMPLATE_ESI-20971098.pdf (310.5 KB)

Issue with the page numbers, showing 1 of 50 instead of 1 of 49
image.png (29.9 KB)

No Issues found while using Aspose-pdf/Aspose-words 16.10 jar, paging issue is faced while using 23.9 Aspose-pdf/Aspose-words jar.

page number issue PDF
2138255-PID_DYNAMIC_FAX_TEMPLATE_ESI-20971098.pdf (304.0 KB)

@manasag

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.

sorry for confusion, we are using Aspose words jar “SECTIONPAGES” to generate the page numbers

@manasag

We are moving this thread to the respective category where you will be assisted shortly.

@manasag Could you please attach your source MS Word document here for testing? We will check the issue and provide you more information.

test.docx (101.0 KB)

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

@manasag UpdateTableLayout 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.

@manasag The following code:

Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.pdf");

produces 2103 pages in the output PDF on my side. Could you please share code you are using for converting document to PDF?

testlatestpdf.pdf (151.2 KB)

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 Could you please provide the code in textual form and zip and attach your template here?

public class SampleBarcode {
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        try{
            //BarCodeBuilder builder = new BarCodeBuilder("01", EncodeTypes.CODE_39_EXTENDED);
            //BarcodeGenerator builder=new BarcodeGenerator (EncodeTypes.CODE_39_EXTENDED,"01");
            //System.out.println(builder);
            com.aspose.words.Document document = new com.aspose.words.Document("C:/Users/c8d2k2/Documents/TEST_ATK_PID_DYNAMIC_FAX_TEMPLATE_ESI_TEST.dot");
            com.aspose.words.DocumentBuilder builder = new com.aspose.words.DocumentBuilder(document);
            builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
            Font font = builder.getFont();
            font.setSize(9);
            font.setName("Times New Roman");
            builder.setBold(true);
            builder.moveToParagraph(2, 0);
            builder.writeln();
            builder.write("Page"+" ");
            builder.insertField("PAGE", null);
            builder.write(" of ");
            //write the total page count
            //builder.write(String.valueOf(numPage));
            builder.insertField("SECTIONPAGES", null);
            builder.getCurrentParagraph().getParagraphFormat()
                    .setAlignment(ParagraphAlignment.CENTER);
            builder.setBold(false);
            document.save("C:/Users/c8d2k2/Desktop/Test_file/testlatestpdf.pdf");
        }catch(Exception e){
            e.printStackTrace();
        }
    }

TEST_ATK_PID_DYNAMIC_FAX_TEMPLATE_ESI_TEST.zip (17.0 KB)

@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)

sample.pdf (304.0 KB)

we are using Aspose words and Aspose pdf 23.9 version jars.
2138255-PID_DYNAMIC_FAX_TEMPLATE_ESI-20971098.pdf (304.0 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.