views:

1107

answers:

2

Hi!

I'm printing a WPF grid. As long as the data fits on one page, everything works fine. But sometimes the grid contains more data. Therefore I need to split the grid into multiple pages. Can anybody help me?

My code looks like this (visual is the grid).

var printCapabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);

var size = new Size(printCapabilities.PageImageableArea.ExtentWidth,
     printCapabilities.PageImageableArea.ExtentHeight);

visual.Measure(size);
visual.Arrange(new Rect(new Point(printCapabilities.PageImageableArea.OriginWidth,
    printCapabilities.PageImageableArea.OriginHeight), size));

printDialog.PrintVisual(visual, "Print ListView");

Should I try another control? I've tried WPF Toolkit DataGrid, but I couldn't manage to get it printed. I've heard something of a flow document, can this help me?

Best Regards
Oliver Hanappi

A: 

Hi,

i got the same problem. Did you found a solution? There must be one ... otherwise you can forget about WPF.

Best regards martin

martin
Have you read my comment? Flow Document works quite fine for me (beside the fact that I cannot split the tables into two if there are too many columns for one page).
Oliver Hanappi
A: 

It sounds like you want to use PrintDocument instead of PrintVisual. You will probably need to implement your own DocumentPaginator class to split your grid into separate printable documents, though.

bearda