Directly by name could be created only:DeviceGray, DeviceRGB, DeviceCMYK, and certain cases of Pattern

Hi,

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()

Next pageCount

I have attached the PDF i am trying to convert.

PDF.zip (15.3 KB)

I have a new exception:

#=z1vBNe7_ipzQ93DIDr3DPdPEzrQGKHoSmel3KR0dqoQQ5WJ0LZQ== occurred
HResult=-2146233088
Message=End of stream
Source=Aspose.PDF
StackTrace:
at #=zA$HonUxmgMK4qzh0$B8_QZHfNHGfS_RqDRopCrJyER1_.#=zyKD9bwc=.#=zrzP_Oxs=()
InnerException:

This also happens on the pngDevice.Process.

Here is the new file:

PDF.zip (39.1 KB)

Here is another exception:

System.Exception occurred
HResult=-2146233088
Message=Object not found
Source=Aspose.PDF
StackTrace:
at #=zoy0j_SCdCCByYcHN$RmXLZeZvbxV.#=zM2FyRYQ=(#=zpXEmdXgmgB_EYelFf19S2bFv$8b_rsE$lw== #=zqIgg8F8=, Boolean #=ziioDRjJalcZ_)
InnerException: System.ApplicationException
HResult=-2146232832
Message=Reference table is not repaired
InnerException:

Here is the file:

PDF.zip (83.3 KB)

It must be noticed that it still does the conversion. But it is a real pain with these messages when I am trying to debug. Can I turn them off?

@runrobert

Thank you for contacting support.

We have not been able to reproduce any of the exception with any of the PDF document shared by you. Below is a screenshot as an overview of exception settings in Visual Studio on our end Exception Settings.png. Moreover, would you please ensure using Aspose.PDF for .NET 19.5 in your environment and then share your kind feedback with us.

Thanks for getting back to me. I will have to upgrade to the 19.5, but won’t be able to right now. When I run the exe, I don’t get the messages, so it is fine like it is. I was trying to understand these messages. Also, I would set the tick box on the “Don’t break with this exception”, but it would keep on coming up. A real pain when I am trying to test a big batch of conversions.

@runrobert

We need your feedback based on latest version of the API because none of the exception has reproduced in our environment. If your current license does not allow you to upgrade then you can test latest version in its full capacity by applying a free 30-days temporary license. Once you complete evaluation process, you may purchase the license to keep using APIs features.

In case you face any issue, please feel free to let us know.