Solved

How to print a Graphic object in c#

Posted on 2006-11-26
3
594 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

947 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now