I have an app that converts the pages of a PDF file to PNG. Every now and then I get an ArgumentException with the message - Directly by name could be created only:DeviceGray, DeviceRGB, DeviceCMYK, and certain cases of Pattern. It still goes ahead with the conversion anyway, but the exception still occurs.
I am also getting some other messages. How do I stop these, or what is the cause of this?
Here is the code:
Dim pdfDocument As New Aspose.Pdf.Document(DocFile)
For pageCount As Integer = 1 To pdfDocument.Pages.Count
Dim pngFilename As String
Dim pngTemp As String
pngFilename = “C:\Temp” & DocumentVersionID & “.” & pageCount & “.png”
Dim imageStream As System.IO.FileStream
imageStream = New System.IO.FileStream(pngFilename, IO.FileMode.Create)
Dim resolution As New Aspose.Pdf.Devices.Resolution(100)
Dim pngDevice As Aspose.Pdf.Devices.PngDevice
pngDevice = New Aspose.Pdf.Devices.PngDevice(resolution)
'Convert a particular page and save the image to stream pngDevice.Process(pdfDocument.Pages(pageCount), imageStream) imageStream.Close() imageStream.Dispose()
I have attached the PDF i am trying to convert.
PDF.zip (15.3 KB)