Null Pointer Exception Occurs on Converting PPTX to PDF in Java

Hello team!

Could you de-obfuscate exception and clarify what is wrong? We are trying to convert regular pptx file (it can be opened by Office), 6Mb, but get the following:

Cannot invoke “com.aspose.slides.internal.jo.qv.fx()” because the return value of “com.aspose.slides.internal.jo.pc.ny()” is null
at com.aspose.slides.t3.fx(Unknown Source)
at com.aspose.slides.t3.fx(Unknown Source)
at com.aspose.slides.mi.fx(Unknown Source)
at com.aspose.slides.en.fx(Unknown Source)
at com.aspose.slides.en.fx(Unknown Source)
at com.aspose.slides.ab.fx(Unknown Source)
at com.aspose.slides.j5.fx(Unknown Source)
at com.aspose.slides.rn.fx(Unknown Source)
at com.aspose.slides.rn.fx(Unknown Source)
at com.aspose.slides.gz.fx(Unknown Source)
at com.aspose.slides.ekm.fx(Unknown Source)
at com.aspose.slides.tb3.fx(Unknown Source)
at com.aspose.slides.r0x.q2(Unknown Source)
at com.aspose.slides.r0x.fx(Unknown Source)
at com.aspose.slides.Presentation.jz(Unknown Source)
at com.aspose.slides.Presentation.fx(Unknown Source)
at com.aspose.slides.Presentation.fx(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)

We use Aspose Slides java 24.12, version 25.2 fails too. I can’t attach file right now, but maybe exception can give us direction to understanding.

@marketlogic

It seems that you are encountering a NullPointerException while trying to convert a PPTX file to PDF using Aspose.Slides for Java. This type of error typically indicates that the code is attempting to access a method or property on an object that has not been initialized (i.e., it is null).

Here are a few steps you can take to troubleshoot and potentially resolve this issue:

  1. Check the PPTX File: Ensure that the PPTX file you are trying to convert is not corrupted. You can try opening it in Microsoft PowerPoint to verify that it displays correctly.

  2. Update Aspose.Slides: Since you mentioned that you are using version 24.12 and that version 25.2 also fails, consider checking if there are any newer versions available. Sometimes, bugs are fixed in later releases.

  3. Review the Code: Make sure that your code for loading and saving the presentation is correct. Here’s a basic example of how to convert a PPTX file to PDF:

    import com.aspose.slides.Presentation;
    import com.aspose.slides.SaveFormat;
    
    public class ConvertToPDF {
        public static void main(String[] args) {
            // Path to the PPTX file
            String dataDir = "path/to/your/presentation.pptx";
            // Instantiate a Presentation object
            Presentation presentation = new Presentation(dataDir);
            // Save the presentation to PDF
            presentation.save("output.pdf", SaveFormat.Pdf);
            // Dispose of the presentation object
            presentation.dispose();
        }
    }
    
  4. Error Handling: Implement error handling in your code to catch exceptions and log more detailed information about the state of your application when the error occurs. This can help you identify the specific part of the code that is causing the issue.

  5. Contact Support: If the problem persists, consider reaching out to Aspose support with the details of your issue, including the stack trace and any relevant code snippets. They may be able to provide more specific guidance based on the internal workings of the library.

If you have any additional details or specific parts of the code that you would like to share, feel free to do so, and I can assist you further!

Dear Professionalize.Discourse!

  1. File can be opened by Microsoft Office
  2. Version 25.2 (which was tried) is last version
  3. Converting code looks very similar to your example.
  4. Error handler is source of attached stacktrace, what additional can I provide?
  5. Problem persists because nothing was changed.
    Our code snippet is:
	  LoadOptions loadOptions = new LoadOptions();
          loadOptions.getBlobManagementOptions().setTemporaryFilesAllowed(true);
          loadOptions
              .getBlobManagementOptions()
              .setPresentationLockingBehavior(PresentationLockingBehavior.KeepLocked);
          loadOptions.getBlobManagementOptions().setMaxBlobsBytesInMemory(maxBlobsBytesInMemory);
          Presentation presentation =
              new Presentation(originalTmpFile.getAbsolutePath(), loadOptions);
              
	  ....
	
          com.aspose.slides.PdfOptions saveOptions = new com.aspose.slides.PdfOptions();
          saveOptions.setDefaultRegularFont(defaultFontName);
          saveOptions.setProgressCallback(
              progress ->
                  log.info(
                      "Saving slides to pdf progress: artifactId={}, state={}",
                      artifactId,
                      progress));
	  ....
          presentation.save(
              outputPdfFile.getAbsolutePath(), com.aspose.slides.SaveFormat.Pdf, saveOptions);
          presentation.dispose();

@marketlogic,
We have opened the following new ticket(s) in our internal issue tracking system and will consider your request according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39627

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.

1 Like

@marketlogic,
Our developers have investigated the case.

The error may indicate that there was a problem reading a chart, specifically the number of category labels.

Perhaps you can separate the charts into individual files to identify which chart is causing the issue, and then send only that file for more detailed analysis.

Hello!

I managed to find slide’s page which gives problem and clean data, so example is attached.
one_slide.zip (165.2 KB)

@marketlogic,
Thank you for the sample presentation. I need some time to check the issue. I will get back to you soon.

@marketlogic,
I get an error when converting the PowerPoint presentation to a PDF document. The sample file was forwarded to our developers. We will keep you updated.

1 Like

The issues you found earlier (filed as SLIDESJAVA-39627) have been resolved in Aspose.Slides for Java 25.3 (Maven, JAR).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.