On Wed, 13 Jun 2007 14:15:34 -0700, Ian Semmel <an****@rocketcomp.com.au>
wrote:
How do you get a Graphics instance of (say) a printer before you start
printing ?
That's a very good question, one for which I don't have a pure .NET
answer. As near as I can tell, .NET does not include this very useful
functionality.
You have a couple of other options:
* Refrain from doing any layout that requires measuring strings or
other things based on the Graphics until you get the first page. This
won't allow you to do any pagination feedback in your application until
the user has printed or previewed the document, but it is a fairly simple
approach.
* Use p/invoke to call CreateDC() with the specific printer driver you
want to use, and then use the resulting DC to create a Graphics instance.
This allows you to get a printer Graphics instance any time you want, but
may lead to having to do other non-.NET stuff as well (for example, I
don't see a way to get the printer driver filename in .NET, so you might
have to use p/invoke to do that as well).
Pete