Does a WPF DocumentPaginator document keep all documents in memory until it finishes the print job?

Strictly theoretical question regarding WPP DocumentPaginator:

When using the WPF DocumentPaginator class to print a multi-page document, does the keeper of all the documents it requests remain in the folder during the history of the print job in memory until the document finishes printing? Or does he ever dispose of any documents that he no longer needs before completing a print job (i.e., to free up memory)? Is there a way to manually tell paginator to free old / unnecessary DocumentPages during printing without exception?

Thanks so much for your help in this!

+3
source share
2

, .

, . , , , GetPage() GetPage.

:

, System.Windows.Controls.PrintDialog.Print(DocumentPaginator, title) :

Public void PrintDocument(DocumentPaginator paginator, string title)
{
   Dictionary<int, DocumentPage> pages = new Dictionary<int DocumentPage>();
   for(int i=0; i<paginator.PageCount(); i++)
   {
      pages.Add(i, paginator.GetPage(i));
      UnknownPrinterEngine.SendPageToPrinter(pages(i)); //this is just imagination
   }
}

- , ( ) . → .

, ( GetPage , DocumentPaginator):

DocumentPage lastLoadedPage = null;
public DocumentPage GetPage(int pageNumber)
{
   if(lastLoadedPage != null)
   {
      lastLoadedPage.Dispose()
   }
   //MyPrintControl should be your custom UserControl which represents the page to print
   myPrintControl pageContent = new MyPrintControl();
   pageContent.Width = PageSize.Width;
   pageContent.Height = PageSize.Height;

   pageContent.Measure(PageSize);
   pageContent.Arrange(new Rect(new Point(0,0), PageSize));

   DocumentPage actualPage = New DocumentPage(pageContent);
   lastLoadedPage = actualPage;
   return actualPage;
}

IDisposable, Dispose lastLoadedPage, .

+2

System.Windows.Xps.VisualsToXpsDocument xps. PrintQueue.CreateXpsDocumentWriter(somePrintQueue). , , .

0

All Articles