When converting the PDF and then to PPTX, report is failed with NullPointerException .
Aspose version:
implementation ‘com.aspose:aspose-pdf:26.7’
implementation ‘com.aspose:aspose-slides:26.8:jdk16’
Stack Trace:
java.lang.NullPointerException: Cannot invoke “com.aspose.slides.t1z.h5()” because “image” is null
at com.aspose.slides.ImageCollection.addImage(Unknown Source)
at com.aspose.slides.t7p.h5(Unknown Source)
at com.aspose.slides.u4t.h5(Unknown Source)
at com.aspose.slides.u4t.h5(Unknown Source)
at com.aspose.slides.SlideCollection.h5(Unknown Source)
at com.aspose.slides.SlideCollection.addFromPdf(Unknown Source)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
at PowerPointService.createPresentationFromPdf(ideaGroovyConsole.groovy:20)
Code Sample
import com.aspose.cells.*
import com.aspose.pdf.*
import com.aspose.pdf.DocSaveOptions
import com.aspose.pdf.PptxSaveOptions
import com.aspose.slides.Presentation
import com.aspose.slides.SlideSizeScaleType
import us.cgt.common.template.PdfService
import java.io.FileInputStream
import com.aspose.pdf.Document
import com.aspose.pdf.PptxSaveOptions
class PowerPointService {
Presentation createPresentationFromPdf(String pdfLocation) {
Integer width = 792
Integer height = 612
Presentation presentation = new Presentation()
presentation.slides.addFromPdf(pdfLocation);
presentation.slides.removeAt(0)
presentation.slideSize.setSize(width, height, SlideSizeScaleType.EnsureFit)
return presentation
}
}
def service = new PowerPointService()
def ppt = service.createPresentationFromPdf( "'Downloads/PPTX aspose test rm-08-17-2026-1786941558033.pdf'")
ppt.save("Downloads/Lorem ipsum.pptx", com.aspose.slides.SaveFormat.Pptx)
The input PDF has been attached.
PPTX aspose test rm-08-17-2026-1786941558033.pdf (200.3 KB)
Thanks,
Nitesh