Print images with the correct size
-
Hi, I am currently working on printing an image from my picturebox but i am finding difficulties regarding this. For example, I have a large image of 1024 x 768. How would i go about working out the correct size regarding the width and height so when the image is printed, it is printed with the original width and height i.e 1024 x 768 in this example. At the moment, i am having trouble doing this. If i do the following the image takes up all of the page(i know why) but the original image doesnt even take up the whole page. I am using A4 piece of paper. Here is the code:
//the width and height I will be using
float destHeight = bitmap.Height /bitmap.VerticalResolution * 90;
float destWidth = bitmap.Width / bitmap.HorizontalResolution * 90;//Boundary for printable area
float highestHeight = destHeight / e.MarginBounds.Height;
float highestWidth = destWidth / e.MarginBounds.Width;I would greatly appreciate if somebody could kindly assist me with this problem. Thanks & Regards,
-
Hi, I am currently working on printing an image from my picturebox but i am finding difficulties regarding this. For example, I have a large image of 1024 x 768. How would i go about working out the correct size regarding the width and height so when the image is printed, it is printed with the original width and height i.e 1024 x 768 in this example. At the moment, i am having trouble doing this. If i do the following the image takes up all of the page(i know why) but the original image doesnt even take up the whole page. I am using A4 piece of paper. Here is the code:
//the width and height I will be using
float destHeight = bitmap.Height /bitmap.VerticalResolution * 90;
float destWidth = bitmap.Width / bitmap.HorizontalResolution * 90;//Boundary for printable area
float highestHeight = destHeight / e.MarginBounds.Height;
float highestWidth = destWidth / e.MarginBounds.Width;I would greatly appreciate if somebody could kindly assist me with this problem. Thanks & Regards,
My guess: The vertical/horizontal resolution of the bitmap is not the same as the printer's resolution, so the destHeight/destWidth are getting incorrect values. You need to use the printer's resolution in your calculations.
-
My guess: The vertical/horizontal resolution of the bitmap is not the same as the printer's resolution, so the destHeight/destWidth are getting incorrect values. You need to use the printer's resolution in your calculations.
Hi, Thanks for replying. How would i go about doing this? Would this work?
PrintDocument document = new PrintDocument(); document.PrinterSettings.DefaultPageSettings.PrinterResolution.X = 300; document.PrinterSettings.DefaultPageSettings.PrinterResolution.Y = 300;
Thanks, -
Hi, Thanks for replying. How would i go about doing this? Would this work?
PrintDocument document = new PrintDocument(); document.PrinterSettings.DefaultPageSettings.PrinterResolution.X = 300; document.PrinterSettings.DefaultPageSettings.PrinterResolution.Y = 300;
Thanks,The printer's resolution would probably be mentioned in the owner's manual. If not, look on the manufacturer's web site. If it's not there, send their support department an email.