We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

A Document with Footnotes and Endnotes produces a NullPointerException when converting to PDF

Hello,

When a document contains a combination of footnotes in one Section and endnotes in another Section, a NullPointerException occurs when it is converted to PDF.

This behavior can be seen in the latest Aspose Words for Java version 22.4, the attached FootnotesEndnotes.docx file and the following Java code:

final String docxFile = [PATH] "FootnotesEndnotes.docx";
Document wdDoc = new Document(docxFile);

final String pdfFile = docxFile.replace(".docx", ".pdf");
Files.deleteIfExists(Paths.get(pdfFile));

final PdfSaveOptions options = new PdfSaveOptions();
// NullPointerException happens during 'save':
wdDoc.save(pdfFile, options);

System.out.println("Created new PDF File: " + pdfFile);

Running the above code should produce a NullPointerException with the following stack:

java.lang.NullPointerException
at com.aspose.words.zzXm9.zzWMR(Unknown Source)
at com.aspose.words.zzXfX.zzWXH(Unknown Source)
at com.aspose.words.zzXfX.zzXWJ(Unknown Source)
at com.aspose.words.zzXOS.zzWRc(Unknown Source)
at com.aspose.words.zzXOS.zzWTK(Unknown Source)
at com.aspose.words.zzXOS.zzuE(Unknown Source)
at com.aspose.words.zzXOS.zzYUy(Unknown Source)
at com.aspose.words.zzrM.zzZ60(Unknown Source)
at com.aspose.words.zzrM.zzZcw(Unknown Source)
at com.aspose.words.zzrM.zzXWr(Unknown Source)
at com.aspose.words.zzrM.zzXVG(Unknown Source)
at com.aspose.words.zzWhs.zzZPF(Unknown Source)
at com.aspose.words.zzYFi.zzmQ(Unknown Source)
at com.aspose.words.zzc7.zzZPF(Unknown Source)
at com.aspose.words.zzYVE.zzWT9(Unknown Source)
at com.aspose.words.zzWA9.zzW9v(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.zzY06(Unknown Source)
at com.aspose.words.Document.getPageCount(Unknown Source)
at com.aspose.words.zzXKH.zzVOH(Unknown Source)
at com.aspose.words.zzXKH.zzXWJ(Unknown Source)
at com.aspose.words.zzK4.zzXWJ(Unknown Source)
at com.aspose.words.Document.zzVOH(Unknown Source)
at com.aspose.words.Document.zzXWJ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at ...

Notes regarding the attached document FootnotesEndnotes.docx:

  • There are 3 Sections where:
  • Section 1 has 4 Footnotes with the option to appear “Below the Text”.
    These footnotes are expected to appear at the end of page 2.
  • Section 2 has 3 Endnotes with the option to appear at the “End of Section”.
    These endnotes are expected to appear at the end of page 4.
  • Section 3 has no footnotes or endnotes.
  • All Sections are continuous sections (i.e. SectionStart.CONTINUOUS).
  • In all cases, the first paragraph in each new Section has the “page break before” setting enabled.
  • The combination of continuous section breaks with the “page break before” setting seems to be contributing towards the issue.

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 FootnotesEndnotes.zip (604.4 KB) attachment contains:

  • FootnotesEndnotes.docx: DOCX file used by the code above.
  • FootnotesEndnotes.pdf: PDF file generated by Microsoft Word. Note that this represents the expected PDF output from the DOCX file.

Thank you!

@oraspose Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23860. We will keep you informed and let you know once it is resolved.