I'm having issues with converting some PDFs to JPEG where I'm getting "System.NullReferenceException: 'Object reference not set to an instance of an object.'" error. I have updated to the latest hotfix 6.3.0.2046. Most PDFs work fine but a subset produced by one specific application causes the error despite the page count of the loaded document showing 1. I've attached one of the offending PDF files and the exception text.
Thanks
Sample/simplified code (.NET Framework 4.7.2):
- Code: Select all
Option Explicit On
Imports System.IO
Imports System.Drawing.Imaging
Imports Spire.Pdf
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim PDFName As String = "C:\PDFTest\Asticou.pdf"
Dim JPGName As String = "C:\PDFtest\Asticou.jpg"
'PDFName = "C:\PDFTest\AllControls.pdf"
'JPGName = "C:\PDFtest\AllControls.jpg"
Dim PdfDoc As New PdfDocument()
PdfDoc.LoadFromFile(PDFName)
MsgBox(PdfDoc.Pages.Count)
Using image As Image = PdfDoc.SaveAsImage(0, 200, 200)
image.Save(JPGName, ImageFormat.Jpeg) 'make the jpeg file
End Using
PdfDoc.Close()
End Sub
End Class