Printpreview of Flowdocument truncated

Jul 19 2011 9:38 AM
Hey there,

my goal is to create a print preview in landscape. Therefore, I use a FlowDocument that is shown via a FlowDocumentReader.

XAML snippet to display the reader:

<StackPanel Grid.Row="0" Grid.Column="2"
            HorizontalAlignment="Stretch">
  <FlowDocumentReader Name="Viewer" Margin="20,20,20,20" Zoom="100"
  BorderThickness="1" BorderBrush="Black"
  Background="White" HorizontalAlignment="Stretch"/>
</StackPanel>



For some reasons, the text is only shown horizontally until approx. the center of the reader. In order to adapt the page to landscape, I use the following code:

// Adjust the page size.
const double inch = 96;

PrintQueue queue = new PrintQueue(new PrintServer(), printer);
PrintTicket ticket = queue.UserPrintTicket;
ticket.PageOrientation = PageOrientation.Landscape;

double width = ticket.PageMediaSize.Width.Value;
double height = ticket.PageMediaSize.Height.Value;

double leftmargin = 1.25 * inch;
double rightmargin = 1.25 * inch;
double topmargin = 1 * inch;
double bottommargin = 1 * inch;

width = width - leftmargin - rightmargin;
height = height - topmargin - bottommargin;

// Option 1
IDocumentPaginatorSource paginator = document as IDocumentPaginatorSource;
paginator.DocumentPaginator.PageSize = new Size(height, width);

// Option 2
PageMediaSize pageMediaSize = new PageMediaSize(height, width);
ticket.PageMediaSize = pageMediaSize;

I played around with Option 1 and 2 to work around that uissue but without much success. If I toggle to Scrollview, the reader shows the full document.

Any help is appreciated.

Best,
Dirk


Answers (1)