My FlowDocument Only Print one Page When I Send it to Print

Marino Liranzo 81 Reputation points
2023-07-21T05:29:37.93+00:00

I have a FlowDocumentScrollViewer control in my project, in this I have a FlowDocument in this I have five BlockUIContainers, each of these BlockUIContainers houses a table of values created by ListView controls, prior to each block I have the respective headers. All my content is displayed as expected, however when sending it to print a problem occur, only a single page of each listView is printed.

private void Button_Click(object sender, RoutedEventArgs e)         {             //Clone the source document             var str = XamlWriter.Save(flowDocument);             var stringReader = new System.IO.StringReader(str);             var xmlReader = XmlReader.Create(stringReader);             var CloneDoc = XamlReader.Load(xmlReader) as FlowDocument;              PrintDialog pd = new PrintDialog();              if (pd.ShowDialog() == true)             {                 CloneDoc.PageHeight = pd.PrintableAreaHeight;                 CloneDoc.PageWidth = 736;                 CloneDoc.PagePadding = new Thickness(50);                 CloneDoc.ColumnGap = 0;                 CloneDoc.ColumnWidth = pd.PrintableAreaWidth;                  IDocumentPaginatorSource idpSource = CloneDoc as IDocumentPaginatorSource;                 pd.PrintDocument(idpSource.DocumentPaginator, "Mi Trabajo de impresion");             }         }
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,275 questions
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,616 Reputation points Microsoft Vendor
    2023-07-21T08:14:02.8133333+00:00

    Hi,@Marino Liranzo. Welcome Microsoft Q&A.

    The issue here is that the DocumentPaginator of FlowDocument does not paginate the BlockUIContainer i.e it does not break the BlockUIContainer content across multiple pages.

    In short, you will have to create multiple BlockUIContainer each containing its itemsControl(ListView).

    If possible, you could also try referring to the approach provided here for a solution's idea.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.