"Parameter is not valid" exception when printing PDF
Posted: Thu Dec 10, 2020 12:55 am
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
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