Print scroll to view documents on multiple pages

I am trying to print my FlowDocument (which is wrapped in a FlowDocumentScrollViewer) because I have a lot of texts / Textbox / combobox and the page height can get high!

I use this:

PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { Scrollvvv.Document.ColumnWidth = printDialog.PrintableAreaWidth; Scrollvvv.Document.ColumnGap = 0; printDialog.PrintDocument(((IDocumentPaginatorSource)Scrollvvv.Document).DocumentPaginator, ServicesLangue.RM.GetString("TITRE_MODIFIER_SALON_EXPOSANT")); } 

My xaml looks like this:

 <FlowDocumentScrollViewer Name="Scrollvvv" VerticalScrollBarVisibility="Auto"> <FlowDocument Name="flowDoc" PagePadding="10"> <Section> <BlockUIContainer> <Grid Name="grid_principale"> <!-- Lot of stuffs here --> </Grid> </BlockUIContainer> </Section> </FlowDocument> </FlowDocumentScrollViewer> 

The fact is that it prints all my data on 1 page, the width is fine (I can add some margin, but that's fine), but it compresses all my controls so that they fit one page in height.

How to fix it? I would just like to disable this auto height and keep the original size.

+2
source share
1 answer

The problem is that you put everything inside one BlockUIContainer. DocumentPaginator has problems with pagination BlockUIContainer, i.e. Splitting it into several pages. If your user interface is static, you can use several BlockUIC objects to port your user interface. those.

  <BlockUIContainer> <Grid Name="grid_principale"> <!-- Grid content here --> </Grid> </BlockUIContainer> <BlockUIContainer> <Grid Name="grid_principale2"> <!-- Grid content here --> </Grid> </BlockUIContainer> 

This will result in multiple pages. Also, before printing, you will need to set FlowDocument.PageHeight.

+3
source

All Articles