Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print a already existing Graphics object

Posted on 2004-08-15
3
Medium Priority
?
226 Views
Last Modified: 2008-02-26
Hello

I have previously created a Graphics object and I would like to print it.

The problem is the PrintPage handler is passed a Graphics in the EventArgs and that's what's used.

I am trying to do something like this
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
  ev.Graphics = g;  //Where g is the graphics I have already saved.  But ev.Graphics is read only...
}

Is there a way to do what I am asking?

Regards,
NTAC
0
Comment
Question by:NTAC
  • 2
3 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11804772
write to a bitmap in a memory stream ... then draw the bitmap object in e.Graphics

0
 
LVL 4

Author Comment

by:NTAC
ID: 11805468
Greg can you post an example of writing to a bitmap in a memory stream?  

I looked up the Bitmap class, and there is a Bitmap(stream) constructor, but I'm not sure how to get my Graphics g into a stream.

Regards,
NTAC
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1400 total points
ID: 11805754
from looking at another question where you detail why you wanted to do this ...

"as for your graphics question I believe this gets done for you as well (it just reuses the graphics object 4 times) it won't ask you to draw it for each of the 4 copies (they are copies I mean why would it ask 4 times)

theres alot of detailed info here http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsPrinting.aspx"

0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

886 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