C
Chris Dunaway
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
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