1

I have long listbox with around 250+ items. It is wrapped with some labels inside a Grid which is again wrapped inside a ScrollViewer. I am using the following code to print the contents of my grid.

PrintDialog printDlg = new PrintDialog();
printDlg.PrintVisual(grid1, "Grid Printing.");

But, it prints all the 250+ items on a single page thereby making everything too small. Why does it not automatically resize automatically? What can I do to achieve proper scaling and pagination?

Any help is highly appreciated. Thanks.

Edit: Just added the following code and now the size is fine.

Size pageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
                // sizing of the element.
                gridinner.Measure(pageSize);
                gridinner.Arrange(new Rect(5, 5, pageSize.Width, pageSize.Height));

But it still prints the content on the first page.

Samarth Agarwal
  • 2,044
  • 8
  • 39
  • 79
  • because `PrintVisual` make the image and then print ... So it fits the image in one page and print it accordingly. Fo normal printing you need to use other Libs – Mohit S Nov 23 '15 at 07:43
  • Can you suggest any such Libraries? – Samarth Agarwal Nov 23 '15 at 07:46
  • This question may be usefull: http://stackoverflow.com/questions/502198/convert-wpf-xaml-control-to-xps-document You can try to covert controls into XPS and then print it. – Michał Komorowski Nov 23 '15 at 08:03

0 Answers0