NullPointerException: Cannot invoke "com.aspose.pdf.internal.l25l.ld.lk()" because "<local2>" is null

Trying to convert a PDF to a PPTX like so:

public class PptxService {
	public byte[] generatePresentation()
		throws IOException {
		try (
			InputStream templateInputStream = this.getClass()
				.getClassLoader()
				.getResourceAsStream("templates/aarPresentation.pdf")
		) {

			if (templateInputStream == null) {
				throw new IllegalStateException("Template not found: templates/aarPresentation.pdf");
			}

			Document doc = new Document(templateInputStream);

			PptxSaveOptions pptxSave = new PptxSaveOptions();
			pptxSave.setSlidesAsImages(false);

			try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
				doc.save(baos, pptxSave);
				return baos.toByteArray();
			}
		}
	}
}

when line doc.save(baos, pptxSave); executes I get the following execption:

java.lang.NullPointerException: Cannot invoke "com.aspose.pdf.internal.l25l.ld.lk()" because "<local2>" is null
        at com.aspose.pdf.internal.l25t.lb.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l25t.lc.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l25t.lj.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l24y.lt.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lj.lf(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lj.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.l0if.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lv.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110n.lc.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lv.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110n.lh.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lv.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110n.ly.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lv.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110n.le.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lv.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110n.lf.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.lk.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.internal.l110y.le.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.l6p.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.l6p.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.ADocument.ld(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.ADocument.lt(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.ADocument.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.Document.lI(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.ADocument.save(Unknown Source) ~[bundleFile:25.11]
        at com.aspose.pdf.Document.save(Unknown Source) ~[bundleFile:25.11]
        at <pkg.removed.for.privacy>.PptxService.generatePresentation(PptxService.java:34) ~[<jar removed for privacy>.jar:?]

With the obfuscation, I have no idea what is wrong…

@4ACode

What we know from the thread

  • The NPE occurs inside Aspose.PDF internal classes when Document.save(baos, pptxSave) is called (stack trace shows bundleFile:25.11).
  • The code loads a PDF from the classpath, creates PptxSaveOptions, sets setSlidesAsImages(false), and saves to a ByteArrayOutputStream.

Likely causes

  1. Version‑specific bug – the stack trace points to the 25.11 bundle. Several PDF‑to‑PPTX conversion bugs were fixed in later releases.
  2. Unsupported PDF content – certain PDF elements (e.g., form fields, embedded files, complex graphics) can trigger a null reference when the converter tries to render them as native PPTX objects.

Next steps to isolate / resolve

  1. Confirm the library version – run System.out.println(com.aspose.pdf.Version.getVersion()); and share the exact version string.
  2. Test with the latest Aspose.PDF for Java (at least 25.12 or newer). Download the newest JAR from the Aspose website or Maven Central and replace the old JAR.
  3. Try default options – remove pptxSave.setSlidesAsImages(false); (or set it to true) and see if the conversion succeeds. This helps determine whether the issue is related to the “text‑as‑shapes” path.
  4. Provide a minimal reproducible PDF – if the problem persists with the latest version, attach a small PDF (≤ 2 pages) that reproduces the NPE. Include any special features (forms, annotations, embedded fonts) it contains.

What to send us

  • Library version.
  • Full stack trace (already provided).
  • The sample PDF (or a sanitized version).
  • Result of step 3 (conversion with default PptxSaveOptions).

Once we have those details we can verify whether it is a known limitation or a defect and, if needed, log an internal issue for a fix.

Results from “next steps”:

  1. There is no com.aspose.pdf.Version class in the aspose-pdf-25.11.jar, so this is not doable.
  2. aspose-pdf-25.11.jar is the latest jar on the Aspose website and Maven Central is back on aspose-pdf-25.9.jar
  3. Same result when i remove pptxSave.setSlidesAsImages(false);
  4. Getting the pdf pared down

@4ACode

What we know (from the thread)

  • NPE is thrown inside Aspose.PDF internal classes when Document.save(baos, pptxSave) is called (stack trace shows bundleFile:25.11).
  • The same exception occurs with the default PptxSaveOptions and after removing setSlidesAsImages(false).
  • com.aspose.pdf.Version class is not present in the 25.11 JAR, so version‑checking via that class is not possible.

Next diagnostic steps

  1. Confirm the exact library build – open the JAR’s META-INF/MANIFEST.MF and copy the value of Implementation-Version (e.g. 25.11.0). Share that string.
  2. Test with the newest Aspose.PDF for Java – at the time of writing a newer build (e.g. 25.12 or later) is available on the Aspose download site. Replace the 25.11 JAR with the latest one and re‑run the conversion.
  3. Provide a minimal reproducible PDF – a small (1‑2 page) PDF that triggers the NPE. If the PDF contains forms, embedded files, or complex graphics, note that as well.
  4. Environment details – Java runtime version (e.g. 17.0.9), OS, and build tool (Maven/Gradle) you are using.

Why these steps matter

  • The stack trace points to a possible version‑specific defect in 25.11 (source: thread).
  • Newer releases contain fixes for several PDF‑to‑PPTX conversion bugs.
  • A minimal PDF allows us to reproduce the issue internally and decide whether it is a limitation or a bug.

If the issue persists with the latest JAR
We will log an internal defect and work on a fix. Please attach the minimal PDF and the manifest version information when you reply.

aarPresentation-part (1).pdf (46.5 KB)

Results from next diagnostics steps:

  1. From the jar manifest:
    Implementation-Version: 25.11
    Release-Date: 2025-11-29
  2. On Aspose.PDF | Java PDF Document Processing Class Library version tab 25.11 is the latest version. How do i get version 25.12?
  3. example pdf attached
  4. Environment information:
    Application runs in a Liferay DXP 7.4.13-u132 podman container
    Java: zulu21
    Gradle 7.2

@4ACode

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-45690

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.