Solved

Print a already existing Graphics object

Posted on 2004-08-15
3
219 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 350 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

12 Experts available now in Live!

Get 1:1 Help Now