Re: Simple printing and graphics
- From: "Kevin Spencer" <uce@xxxxxxx>
- Date: Wed, 5 Jul 2006 17:50:07 -0400
First of all, everything in the printed page is graphics, including text.
The PrintDocument class is what does the Printing. When you call the Print
method of the PrintDocument class, it prints. How you get your graphics into
it is by wiring up an event handler to the PrintDocument.Print event. This
event passes a System.Drawing.Printing.PrintPageEventArgs instance, which
contains, among other things, the Graphics object you need to draw to.
It's a bit more complex than that, however. The PrintDocument class also has
a PageSettings and PrinterSettings instance in it. These determine which
Printer to print to, any additional Printer settings, and page information
about the page to print to. This includes (very important) the Printable
Area of the page, and the Margins of the page. The Graphics instance passed
will be relative to the Printing area of the page, but may or may not
(optionally) include the margins.
The Print event of the PrintDocument is the place where you can do your
paging. The PrintPageEventArgs class has a member called "HasMorePages." If
you set this to true, the handler will be called again. Since the handler
does the drawing, it can draw as many pages as you wish, just by changing
what it draws with each event.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
Big thicks are made up of lots of little thins.
"Chris Dunaway" <dunawayc@xxxxxxxxx> wrote in message
news:1152123745.279038.280900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The method for printing documents in .Net can be confusing, especially
for newer users. I would like to create a way to simplify this
process. My idea would be implemented using a PrintDocument (much like
the current model), but my PrintDocument would have a Pages collection
such that each time you need to have an additional page, you would just
add another page to the collection and then use the page object for the
actual drawing etc. Finally, when you wanted to submit the document to
the printer, you would call the Print method. The following pseudo
code shows what I intend:
PrintDocument pd = new PrintDocument();
//Add the first page
Page p = pd.AddPage();
//Here, draw things, data, etc. to the page
p.DrawString(x, y, font, "string to be drawn");
p.DrawCircle(x, y, radius);
if (anotherpageneeded)
p = pd.AddPage();
//More drawing to the page here
//Finally, submit the document to the printer
pd.Print();
My question, is how to represent or "store" the pages graphics. Should
I create a Graphics object internally to the page object? Or should I
create a "pseudo" drawing language and use something like a hashtable
to store each drawing command. Can a Graphics object be created and
then somehow "copied" to a destination graphics object?
I'm just looking for a suggestion on how to persist in each page object
the necessary commands to render the page to the printer's graphics
object. I guess I'm wondering if a Graphics object can be created,
drawn to, and then copied or rendered onto another Graphics object?
And how do I create a Graphics object that is the same scale, etc. as
the one used by the printer?
Thanks for any suggestions,
Chris
.
- Follow-Ups:
- Re: Simple printing and graphics
- From: Chris Dunaway
- Re: Simple printing and graphics
- References:
- Simple printing and graphics
- From: Chris Dunaway
- Simple printing and graphics
- Prev by Date: Re: trigger bswap generation in native comp. (was: littleEndian/bi
- Next by Date: Re: Regular Expression Text
- Previous by thread: Simple printing and graphics
- Next by thread: Re: Simple printing and graphics
- Index(es):
Relevant Pages
|
Loading