System.ArgumentNullException: Value cannot be null.Parameter name: ptr

Hi There,

We are getting the below error randomly while printing the PDF document through windows service.

System.ArgumentNullException: Value cannot be null.
Parameter name: ptr

at System.Runtime.InteropServices.Marshal.StructureToPtr(Object structure, IntPtr ptr, Boolean fDeleteOld)
at System.Drawing.Printing.PageSettings.CopyToHdevmode(IntPtr hdevmode)
at System.Drawing.Printing.PrinterSettings.GetHdevmode()
at System.Drawing.Printing.PageSettings.get_Bounds()
at Aspose.Pdf.Facades.PdfViewer.PrintDocumentWithSettings(PageSettings pageSettings, PrinterSettings printerSettings)

We are using Aspose pdf library(.NET) 9.0.0

Can you please help us to fix this issue.

Thanks & Regards,

Shivarama shetty

Hi Shivarama,


We are sorry for the inconvenience. I am afraid it is difficult to suggest you anything without replicating the issue at our end. Please share a sample problematic PDF document, so we test the scenario and provide you more information accordingly.

Best Regards,