0

I have a WPF Window that I want to save to an XPS file (or really, any type of file that would store the window image). This window contains a lengthy DataGrid. So far I am able to write to an XPS file, but the resulting document contains only one page, so most of the DataGrid rows are missing. How can I get the XPSDocumentWriter to use as many pages as necessary?

Here is what I've got so far (I've turned off the grid scroll bar and autosized the window to make sure it is full-sized before writing to XPS file):

Dim visual = CType(Me.Content, Media.Visual)

            Me.LogGrid.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden
            Me.SizeToContent = Windows.SizeToContent.WidthAndHeight

            Dim xd As New System.Windows.Xps.Packaging.XpsDocument(file, IO.FileAccess.ReadWrite)

            Dim xw = System.Windows.Xps.Packaging.XpsDocument.CreateXpsDocumentWriter(xd)
            xw.Write(visual)
            xd.Close()
Tekito
  • 840
  • 8
  • 24
  • 1
    You have to handle all custom pagination code by yourself. This is in no way simple. If I were going to do it, I'd come up with one or more user controls that handle paginated data, then split the rows along known row counts (e.g., first page handles 10 rows, overflow page handles 80 rows), fill 'em up and write 'em to the document. Or try to create a custom [document paginator like in this CodeProject article](http://www.codeproject.com/Articles/31834/FlowDocument-pagination-with-repeating-page-header). –  Sep 16 '13 at 14:07

1 Answers1

0

I think Will's comment is probably the right answer.

Tekito
  • 840
  • 8
  • 24