Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different orientation in a Multiple page PrintDocument (How to)

Tags:

c#

.net

printing

I have a PrintDocument that has several pages. One page in that document must be in a Landscape orientations instead of Portrail.

As the PrintPage event is triggered for each page on the document... at the very begining of that event handler I set the PrintPageEventArgs.PageSettings.Landscape to true.

That doesn't works on THAT page... but I can see that Landscape is set to true and taked into account in the NEXT page.

I assume that somehow... after the event is triggered for a certain page you are not able to change the page orientation. That is more of less logic if you think it... but HOW COULD I SET THAT FLAG before EVENT fires in a multiple page PrintDocument?

Note: I don't know in advance if the "next" page will going to actually need a Landscape orientation.

like image 603
Romias Avatar asked Mar 07 '09 01:03

Romias


1 Answers

I'm no expert at printing in .NET; however using Reflector; it looks like you might want to handle the QueryPageSettings event on PrintDocument. It looks like PrintController's private PrintLoop() method, will invoke events in this order for each page:

  1. QueryPageSettings
  2. StartPage
  3. PrintPage
  4. EndPage

Hope this helps.

like image 101
Phil Price Avatar answered Sep 21 '22 09:09

Phil Price