473,805 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print graphics with te right size

Guy
How can i print a image to the printer in centimeters?

Nov 20 '05 #1
8 5388
"Guy" <gh**********@p andora.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.PrintD ocument object in e.graphics. Use
e.graphics.draw image to draw the image (surprise). DrawImage is overloaded.
One version takes a GraphicsUnit argument. Pass GraphicsUnit.Mi llimeter
(multiply centimeters by 10 before ;)
--
Armin
Nov 20 '05 #2
Guy
I have done all that before, but wen i pass GraphicsUnits.M illimeter, 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*******@free net.de> schreef in bericht
news:O2******** ******@tk2msftn gp13.phx.gbl...
"Guy" <gh**********@p andora.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.PrintD ocument object in e.graphics. Use
e.graphics.draw image to draw the image (surprise). DrawImage is overloaded. One version takes a GraphicsUnit argument. Pass GraphicsUnit.Mi llimeter
(multiply centimeters by 10 before ;)
--
Armin


Nov 20 '05 #3


Armin
I have done all that before, but when i pass GraphicsUnits.M illimeter, 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
"Guy" <gh**********@p andora.be> schrieb
I have done all that before, but wen i pass GraphicsUnits.M illimeter,
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
Guy
Armin
I get a messagebox with the following message when i pass the parameter
GraphicsUnit.Mi llimeter.
Btw i get the same error with all members of GraphicsUnit exept Pixel.

An unhandled exception of type 'System.NotImpl ementedExceptio n' occurred in
system.drawing. dll

Additional information: Not implemented.
"Armin Zingler" <az*******@free net.de> schreef in bericht
news:#H******** ******@TK2MSFTN GP11.phx.gbl...
"Guy" <gh**********@p andora.be> schrieb
I have done all that before, but wen i pass GraphicsUnits.M illimeter,
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
"Guy" <gh**********@p andora.be> schrieb
Armin
I get a messagebox with the following message when i pass the
parameter GraphicsUnit.Mi llimeter.
Btw i get the same error with all members of GraphicsUnit exept
Pixel.

An unhandled exception of type 'System.NotImpl ementedExceptio n'
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
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.Mi llimeter, or is it only on my pc?
"Armin Zingler" <az*******@free net.de> schreef in bericht
news:#9******** ******@TK2MSFTN GP12.phx.gbl...
"Guy" <gh**********@p andora.be> schrieb
Armin
I get a messagebox with the following message when i pass the
parameter GraphicsUnit.Mi llimeter.
Btw i get the same error with all members of GraphicsUnit exept
Pixel.

An unhandled exception of type 'System.NotImpl ementedExceptio n'
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
"Guy" <gh**********@p andora.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.Mi llimeter, 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2248
by: Devin Dow | last post by:
Print Preview looks perfect, but the Printout is cut off (extends off the page). Has anyone else experienced this? A3 paper size seems to exacerbate the problem. I can't believe it because the same code is executed with the same exact values when Printing and doing Print Preview. I've seen something like this in old Win32 programming caused by bad
1
11389
by: VJ | last post by:
I have a sample code.. below with my Print problem... I am not able to get the Label on Image print at the right location.. VJ private Label label4 = new Label(); Form1's Load... label4.BackColor=Color.White; label4.BorderStyle=BorderStyle.FixedSingle;
2
1922
by: Craig Scheets | last post by:
I have writting an application that prints fine, but I have to do a TranslateTransform on the graphics in the OnPagePrint event to get place output at exact X,Y (the application prints checks and must be placed accurately). However, when I do a print preview if I do the same translateTransform part of the graphics is often just off the edge of the preview. Is there a way to determine inside the OnPagePrint event if it's just a preview...
0
1609
by: melanieab | last post by:
Hi, I have a tabpage with a print button. This button tries to do a print screen, and it works fine the first time, but if I try to press print again, I get error: An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll Additional information: A generic error occurred in GDI+. I'm going about print-screening by first capturing a bitmap of the screen,
16
9380
by: Neal | last post by:
Hi, I saw the VB6 Code to do this at this link: http://www.dotnet247.com/247reference/msgs/11/56581.aspx The VB6 Code reads as follows: Private Type Rect Left As Long
3
2257
by: Neal Miller | last post by:
Hi Thanks to all of your help, I've got a working PrintRTF module that prints out RTF code, and it works well. The next issue to overcome is to determine how to page-break text that is too long for one page Is there some way to identify exactly how many characters I can print before I run out of room in the current rectangle that defines the output, and do to a new page. A VB.NET code sample with a loop to handle multiple pages would be...
3
2233
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. But while trying to insert a text box to see when a method is used, and putting a counter to bump some variable? The textbox sits there unchanged. I put a breakpoint at the text write
1
1787
by: gleave | last post by:
Hi, below is the code i got to print a datagridview, the trouble is it also prints visible columns which i don't want to be printed. Does anyone have any ideas on how i could change the code so it won't print these columns? Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint datagridprint = DataGridView1 oStringFormat = New...
4
3083
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've a document which i'm creating and printing. i want to print 2 copies: 1. regular A4 copy 2. 70% of A4 size (like in copy machine, where you can choose the size of copy). how can i do that?
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.