Printing Fixed document in WPF

4.1k views Asked by At

I have a fixed document which contains 70 fixed pages approx., When I tried to print that fixed page by the below code, I got exception

code:

PrintDialog dialog = new PrintDialog();
dialog.PrintDocument(FixedDocument.DocumentPaginator, "Print");

Exception : Insufficient memory to continue the execution of the program.

I thought of printing that 70 pages one by one, but I did not get any strike of the way though I surfed though google....Any way....?

1

There are 1 answers

0
Kcvin On

Interesting problem you have here. If you found a solution I'm interested in knowing it; and you should answer your own question if you did solve it.

As for printing pages one by one, here's something you could try.

PrintDialog dialog = PrintDialog();
var doc = FixedDocument.DocumentPaginator; 
for(int i = 0; i < doc.PageCount; i++)
{
    dialog.PrintVisual(doc.GetPage(i).Visual, "Page " + i);
}

This should answer the question, though I don't think I would follow this method since it'll send 70 individual print jobs to the printer. Instead, figure out what's consuming all your resources using the PrintDocument call.