I have a report defined in a FlowDocument. In that report I have some sections that I want to print in landscape mode. In order to do that I have written a dirty DocumentPaginator hack that creates a landscape oriented FlowDocument for sections marked as landscape.
public override DocumentPage GetPage(int pageNumber)
{
// some code
if (section.Name.Equals("landscapePage"))
{
var landscapeDocument = new FlowDocument();
landscapeDocument.PageWidth = document.PageHeight;
landscapeDocument.ColumnWidth = document.PageWidth - 50;
landscapeDocument.PageHeight = document.PageWidth;
landscapeDocument.Blocks.Add(section);
var landscapePaginator = ((IDocumentPaginatorSource)landscapeDocument).DocumentPaginator;
var landscapePage = landscapePaginator.GetPage(0);
return landscapePage;
}
// more code
This looks just as expected if I print to an XPS document. The landscape marked pages are shown in landscape mode in the XPS Viewer. However if I print the document either directly or from the XPS Viewer the printer doesn't rotate the landscape page and the right side of the content is cropped.
I also tried to make a mixed mode document in Word, that prints as expected, but if I save the same document as XPS and print it using the XPS Viewer, the landscape pages get cropped. This makes me wonder if XPS supports mixed page orientations at all.
I know that I could extract a Visual from the page and add a 90 degree rotation transform. I have tried that and it works fine when printing, but if saved as XPS or PDF the pages are obviously rotated which is less than optimal when the print is viewed on a monitor.
Is there a way to print FlowDocuments in mixed orientations without using a rotate transform?