"Parameter is not valid" exception when printing PDF

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Moderator: Alex

Post Reply
IntegraHarlan
Posts: 84
Joined: Fri Jan 24, 2020 3:37 am

"Parameter is not valid" exception when printing PDF

Post by IntegraHarlan »

Hi,
When printing large PDF documents I am getting a "Parameter is not valid" exception.
This is happening in the overridden DrawImage method. It looks like the graphics parameter is corrupted at some point when this method is called.
This appears to be happening when running in 32 bit.

I am able to reproduce this in your PrintDemo App.
When I load a large pdf file (in this case a 200 page file), I will get the same exception in the PrintDemo app when it is built for the X86 configuration.
I have a sample PDF file that I can reproduce this issue with but there does not appear to be a way to attach the file to this post.
If you would like this file to test with, please advise on how I can get it to you.

Here is a stack trace:
System.ArgumentException
HResult=0x80070057
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.get_Transform()
at System.Drawing.GraphicsContext..ctor(Graphics g)
at System.Drawing.Graphics.Save()
at Vintasoft.Imaging.Print.ImagePrintDocument.꬐(RenderImageCommand A_0, VintasoftImage A_1, Graphics A_2, RectangleF A_3, RectangleF A_4)
at Vintasoft.Imaging.Print.ImagePrintDocument.DrawImage(VintasoftImage image, Graphics graphics, RectangleF sourceRect, RectangleF destRect, Single printerResolutionX, Single printerResolutionY)
at Vintasoft.Imaging.Annotation.Pdf.Print.AnnotatedPdfPrintDocument.DrawImage(VintasoftImage image, Graphics graphics, RectangleF sourceRect, RectangleF destRect, Single printerResolutionX, Single printerResolutionY)
at PrintDemo.CustomImagePrintDocument.DrawImage(VintasoftImage image, Graphics graphics, RectangleF sourceRect, RectangleF destRect, Single printerResolutionX, Single printerResolutionY) in D:\Temp\VintaSoftDemo\Imaging .NET v9.1\Examples\WinForms\CSharp\PrintDemo\CustomImagePrintDocument.cs:line 369
at Vintasoft.Imaging.Print.ImagePrintDocument.꬐(Graphics A_0, RectangleF A_1, RectangleF A_2, Single A_3, Single A_4)
at Vintasoft.Imaging.Print.ImagePrintDocument.꬐(Graphics A_0, RectangleF A_1, Single A_2, Single A_3)
at Vintasoft.Imaging.Print.ImagePrintDocument.OnPrintPage(PrintPageEventArgs e)

Building our application for the x64 configuration is not an option at this time.
Thanks
Harlan
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

Re: "Parameter is not valid" exception when printing PDF

Post by Alex »

Hi Harlan,

For understanding the problem we need to reproduce the problem on our side.

Please add sample PDF file to archive, upload archive to any free upload server (for example, Google Drive) and send us (to support@vintasoft.com) an URL for archive downloading. If file contains sensitive information, please create archive with strong password and also send us password to the archive.

Best regards, Alexander
IntegraHarlan
Posts: 84
Joined: Fri Jan 24, 2020 3:37 am

Re: "Parameter is not valid" exception when printing PDF

Post by IntegraHarlan »

Thank you for your quick reply.
I have uploaded a sample PDF file to google drive and sent an email to your support email address with the link to get the file.
Please let me know if you have any issues getting the PDF file.

Thanks
Harlan
IntegraHarlan
Posts: 84
Joined: Fri Jan 24, 2020 3:37 am

Re: "Parameter is not valid" exception when printing PDF

Post by IntegraHarlan »

Thank you for your quick reply.
I have uploaded a sample PDF file to google drive and sent an email to your support email address with the link to get the file.
Please let me know if you have any issues getting the PDF file.

Thanks
Harlan
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

Re: "Parameter is not valid" exception when printing PDF

Post by Alex »

Hi Harlan,

We received PDF document and reproduced the problem in 32-bit version of PrintDemo. Now we need some time to investigate the problem. I will contact you when we have result.

Best regards, Alexander
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

Re: "Parameter is not valid" exception when printing PDF

Post by Alex »

Hi Harlan,

We reproduced the problem in 32-bit version of PrintDemo and here are results:
  • We optimized memory usage in 32-bit application and now 32-bit version of PrintDemo uses less memory.
  • Optimization does not solve the problem and PrintDemo still cannot preview your PDF document (201 page document with a lot of vector text and vector graphics) because PrintDemo uses System.Drawing.Printing.PrintDocument control for page preview. This control stores all preview pages in memory, control works very not effectively and it is not intended for previewing large count of pages. We will update code of PrintDemo and will use Vintasoft.Imaging.UI.ImageViewer control instead of System.Drawing.Printing.PrintDocument control.
  • I suggest you to use Vintasoft.Imaging.UI.ImageViewer control instead of System.Drawing.Printing.PrintDocument control if your application is 32-bit application and you want to preview large count of pages.
Best regards, Alexander
Post Reply