Solved

How to print a Graphic object in c#

Posted on 2006-11-26
3
604 Views
Last Modified: 2012-06-21
what is the easiest way to print a graphic object.

(I have used the graphic object to display some bmp files)

thanx :)

0
Comment
Question by:Knightley
3 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 18014806
0
 
LVL 1

Author Comment

by:Knightley
ID: 18014889
is there any example on this?
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 50 total points
ID: 18015299
// create a document
PrintDocument pd = new PrintDocument();
//bind a delegate to its print page event
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// create a print dialog
PrintDialog pDlg = new PrintDialog();
// give it the document
pDlg.Document = pd;
// show it
pDlg.ShowDialog(this);


// here's our delegate method
private void pd_PrintPage(object sender, PrintPageEventArgs e) {
    // get the graphics of the print document
    Graphics g = e.Graphics;
    // here draw your image onto the graphics using g.DrawImage() or whatever suits you
    // tell the print dialog there are no more pages
    e.HasMorePages = false;
}
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question