By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,572 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,572 IT Pros & Developers. It's quick & easy.

Print graphics with te right size

P: n/a
Guy
How can i print a image to the printer in centimeters?

Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Guy" <gh**********@pandora.be> schrieb
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 ;)
--
Armin
Nov 20 '05 #2

P: n/a
Guy
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.

"Armin Zingler" <az*******@freenet.de> schreef in bericht
news:O2**************@tk2msftngp13.phx.gbl...
"Guy" <gh**********@pandora.be> schrieb
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 ;)
--
Armin


Nov 20 '05 #3

P: n/a


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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4

P: n/a
"Guy" <gh**********@pandora.be> schrieb
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

Nov 20 '05 #5

P: n/a
Guy
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.
"Armin Zingler" <az*******@freenet.de> schreef in bericht
news:#H**************@TK2MSFTNGP11.phx.gbl...
"Guy" <gh**********@pandora.be> schrieb
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


Nov 20 '05 #6

P: n/a
"Guy" <gh**********@pandora.be> schrieb
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?
--
Armin

Nov 20 '05 #7

P: n/a
Guy
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?
"Armin Zingler" <az*******@freenet.de> schreef in bericht
news:#9**************@TK2MSFTNGP12.phx.gbl...
"Guy" <gh**********@pandora.be> schrieb
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?
--
Armin

Nov 20 '05 #8

P: n/a
"Guy" <gh**********@pandora.be> schrieb
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.
--
Armin

Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.