views:

451

answers:

3

I have a document that I want to be flipped / rotated 180 degrees when printed. (This is due to the orientation of label stock in the printer).

There is a property PrintDocument.PrinterSettings.LandscapeAngle but it is read only.

I think this property is influenced by the printer driver and therefore not 'settable'.

Is there a nice way i can rotate the print by 180 degrees without having to do anything too nasty?

A: 

You want PrintDocument.DefaultPageSettings.Landscape

Joel Coehoorn
But i want it 180 degrees from what Landscape is.
Simon_Weaver
Can't you just turn the label stock around?
Joel Coehoorn
Or is it spooled rather than in a tray?
Joel Coehoorn
+1  A: 

I guess that depends on what you define as being "anything too nasty" :-)

The PrintDocument class has a Graphics object you can use for this, which in turn has a TranslateTransform and RotateTransform method that will allow you to get things where you need them to be.

It's often worth taking a copy of the graphics object before you manipulate it so you can restore it back again when you're done.

Rob Cowell
untested but sounds promising!
Simon_Weaver
Have used it successfully in some PDF-wrangling code at my last employer. Alas, since I've left, I don't have access to the actual code, but its pretty easy to implement.
Rob Cowell
+1  A: 

have you tried before assigning it to the printer GDI rotate the image it self? thats what i did:

                _currentPage = Image.FromStream((MemoryStream)_queue.Dequeue());
                pageHeight = _currentPage.Height;
                pageWidth = _currentPage.Width;

                if (pageHeight < pageWidth)
                {
                    _currentPage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    pageHeight = _currentPage.Height;
                    pageWidth = _currentPage.Width;                      

                }
greektreat