Print graphics with te right size

  • Thread starter Thread starter Guy
  • Start date Start date
Guy said:
How can i print a image to the printer in centimeters?

You get a graphics object in the event handler for the PrintPage event of a
System.Drawing.Printing.PrintDocument object in e.graphics. Use
e.graphics.drawimage to draw the image (surprise). DrawImage is overloaded.
One version takes a GraphicsUnit argument. Pass GraphicsUnit.Millimeter
(multiply centimeters by 10 before ;)
 
I have done all that before, but wen i pass GraphicsUnits.Millimeter, i get
an error, something like "Not Implemented". Is there no way that i can
calculate how many pixels there are in 1 centimeter?

Thanks for your reply.
 
Guy said:
I have done all that before, but wen i pass GraphicsUnits.Millimeter,
i get an error, something like "Not Implemented".

What is the exact version of "not implemented"? ;-)
Is there no way
that i can calculate how many pixels there are in 1 centimeter?

The graphics object has two properties: dpix and dpiy. You can use them to
calculate the pixels. Example: Bitmap width is 150 pixel, width on the
printer should be 5cm, dpix is 300 => destination width in pixels on the
printer = width_in_cm / 2.54 * e.graphics.dpix = 5 / 2.54 * 600 = 1181
pixels.
 
Armin
I have done all that before, but when i pass GraphicsUnits.Millimeter, i
get an error something like Not Implemented. Is there no way that i can
calulate how many pixels there are in 1 centimeter?

Thanks for your reply.
 
Armin
I get a messagebox with the following message when i pass the parameter
GraphicsUnit.Millimeter.
Btw i get the same error with all members of GraphicsUnit exept Pixel.

An unhandled exception of type 'System.NotImplementedException' occurred in
system.drawing.dll

Additional information: Not implemented.
 
Guy said:
Armin
I get a messagebox with the following message when i pass the
parameter GraphicsUnit.Millimeter.
Btw i get the same error with all members of GraphicsUnit exept
Pixel.

An unhandled exception of type 'System.NotImplementedException'
occurred in system.drawing.dll

Additional information: Not implemented.

Oh, I see - but I don't know why. Does the other suggestion (concerning
graphics.dpix resp. dpiy) help?
 
I am working on it, and it seems to go the right way. Thank you verry much
for your efford. Do you get the same error when you pass then parameter
GraphicsUnit.Millimeter, or is it only on my pc?
 
Guy said:
I am working on it, and it seems to go the right way. Thank you verry
much for your efford. Do you get the same error when you pass then
parameter GraphicsUnit.Millimeter, or is it only on my pc?

I don't know, I've never tried. :)

.......later: Yes, I also get the exception.
 
Back
Top