Hello,
We are seeing unexpected output when we merge three documents and generate a PDF.
Relevant notes:
- The first document (aka the “base doc”) has four footnotes.
This document has 2 pages and the footnotes are expected to appear at the bottom of page 2. - The second document has 3 endnotes - which are formatted to appear at the end of the section.
This document has 2 pages and the endnotes are expected to appear at the end of page 2. - The third document has no footnote or endnotes but will be included in the merged document.
This document has 1 page. - When these documents are merged, they are separated by a continuous section break.
- The first paragraph of document 2 and 3 have the “page break before” setting enabled.
- When the PDF is generated from the merged documents, it correctly produces a 5 page PDF.
However, the endnotes from the second document appear on the 2nd page of the PDF - which pertains to the 1st document.
This behavior can be seen in the latest Aspose Words for Java version 22.4, the attached documents and the following Java code:
final String fileFolder = "[PATH]";
final Document baseDoc = new Document(fileFolder + "Footnotes.docx");
final String[] mergeDocs = { fileFolder + "Endnotes.docx",
fileFolder + "Document3.docx"};
for (String docToMerge : mergeDocs) {
Document mergeDoc = new Document(docToMerge);
// add a continuous section break on the mergeDoc
mergeDoc.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
// merge the two documents
baseDoc.appendDocument(mergeDoc, ImportFormatMode.USE_DESTINATION_STYLES);
baseDoc.cleanup();
}
// save the base Doc as PDF
final String pdfFile = fileFolder + "MergedDocs.pdf";
Files.deleteIfExists(Paths.get(pdfFile));
baseDoc.save(pdfFile, new PdfSaveOptions());
System.out.println("Created merged PDF File: " + pdfFile);
Running the above code should produce a file named MergedDocs.pdf
. If you view the PDF and navigate to page 2, you should see that the endnotes from Endnotes.docx
appear along with the footnotes from Footnotes.docx
. We expect the endnotes to appear on page 4 of the PDF.
Environment Details:
- Aspose Words for Java 22.4
- Java version 1.8.0_211
- Windows 10 OS (but also reproducible under Linux).
File description in the MergedFootnotesEndnotes.zip
(96.9 KB) attachment contains:
- Footnotes.docx: Base DOCX file with footnotes used by the code above.
- Endnotes.docx: DOCX file with endnotes used by the code above.
- Document3.docx: DOCX file with no footnotes or endnotes used by the code above.
- MergedDocs.pdf: PDF file generated after running the code above (on our environment).
Thank you!