I have an extra blank space, appearing as a paragraph tag at the end of the document. In some cases, the document is filled with characters until the end of any page, and while downloading any such documents, users are seeing an extra blank page at the end of the file. That is, the extra space placed on the new page, but actually, it is a blank page.
This is happening irrespective of the document format i.e., word or pdf. However, we have rectified this issue in the word document by removing the extra blank pages. That is, by checking the last child node of the last paragraph of the last section in the body. Unfortunately, the same logic doesn’t work out for PDF formats.
Do we have any other procedures to remove the blank pages in the PDF format? We are using a Java-based application. Any bits of help or ideas are highly appreciated!
Please ZIP and attach your simplified input Word document and Aspose.Words generated PDF file showing the undesired behavior here for testing. Please also share the simplified source code that you are using on your end. We will then investigate the issue on our end and provide you more information.
Please find below, the java code to save the document in DOCX/PDF formats. Both formats are saved with an additional empty page.
ASPOSE-Download-Document.zip (97.4 KB)
I have added the method to remove the empty pages in the class file. As I said in my query, it is supported for DOCX format but not for PDF format.
Please let me know if you need any further inputs from my side.
Thanks for sharing the detail. Please call Document.updatePageLayout method before saving the document to PDF as shown below to get the desired output.
OutputStream out = new FileOutputStream(MyDir + "my-file-with-blank-pages.docx"); //DOCX
OutputStream out2 = new FileOutputStream(MyDir + "my-file-with-blank-pages.pdf"); //PDF
doc.save(out, SaveFormat.DOCX); //DOCX
doc.save(out2, SaveFormat.PDF); //PDF