Solved

How to print a Graphic object in c#

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can my static class become undefined?? 8 47
MediaHelp 4 21
localhost: This site can’t be reached  localhost refused to connect. 2 45
Hey!!!! 1 20
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 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

14 Experts available now in Live!

Get 1:1 Help Now