How can I size a Form or a FlowLayoutPanel for printing larger than the Screen size? RRS feed

  • Question

  • I have a Form whose main panel is a FlowLayoutPanel that is exactly what I want to print (it is designed to look like a nicely formatted document... no buttons, etc. ... you right-click for commands).

    So, I take advantage of DrawToBitmap to implement printing for almost free... I simply resize the Form such that the main panel is the size of the sheet of paper the user wants to print on (minus margins), which causes it to automatically flow its contents properly for that size.  I then just use DrawToBitmap to render that FlowLayoutPanel and all its contents to the printed page.  I can even scale to fit by growing the window larger than the page size (same aspect ratio), and then scaling down the Bitmap I get from DrawToBitmap.  Works great...

    BUT it only works if your screen is larger than the page size!  Because any attempt to resize a Form or Control larger than the size of the screen + 12 pixels in either direction gets thwarted.

    Ugh!!  Why tease me with the simplicity and utility of DrawToBitmap if you're going to kill its applicability by refusing to resize larger than the screen?  (rhetorical)

    My questions:

    Is there a way to circumvent that limit and get the Form or the FlowLayoutPanel to resize larger than the screen?

    If not, is there a way to get to the FlowLayoutPanel's scrolled surface (not just the portion scrolled into view) such that I can size it to match the printed page and such that I can call DrawToBitmap on it?

    If not, is there some other way to leverage my existing layout functionality to print?  Or am I stuck essentially rewriting all that WinForms code just to generate the same Bitmap it'll already generate if my screen is bigger than my printed page??

    Tuesday, December 18, 2012 9:47 AM