i have a form, with a few text box's, and a background image, when i click the button to produce the pdf it often creates this Parameter is not valid exception (argumentException was unhandled)..

Bitmap back = iDMS.Properties.Resources.corporateLetterHeadPage1;
            back.SetResolution(300, 300);  <------ error is here..

the image is not massive, its the size of an A4 at 300dpi...

i know the image is there, and the image is working correctly.. is there a work around or something that i've missed?

The SetResolution function accepts to float's as parameters, you are passing to int's. To fix your error you need to pass like so:

back.SetResolution(300.0F, 300.0F);

The SetResolution function accepts to float's as parameters, you are passing to int's.

Since the range of integers is smaller than the range of floats the system will implicitly cast them for you. This isn't the problem.

The only thing I can find about this error says that the image has been disposed even though you still have a reference to it. You'll have to make sure that nothing in your code (or anything in any libraries you might be using) has disposed of the image.

This type of error can happen if your application is using a lot of memory and the GC decides it needs to free some up.

i seemed to have solved the problem by setting the image as a local file which it loads into the app..

Bitmap back = iDMS.Properties.Resources.corporateLetterHeadPage1;

produces the error,
but

Bitmap back = new Bitmap.fromfile("c:image.jpg");

works as required...

thanks for the help...

This question has already been answered. Start a new discussion instead.