Share via

StandardPrintController.OnStartPage(PrintDocument document, PrintPageEventArgs e) is slow

JAYLON LIU 1 Reputation point
2021-12-08T03:46:44.957+00:00

What factors will affect the performance of OnStartPage(PrintDocument document, PrintPageEventArgs e) method?

Windows for business | Windows Server | User experience | Print jobs
Windows for business | Windows Server | User experience | Other
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


1 answer

Sort by: Most helpful
  1. Jack J Jun 25,306 Reputation points
    2021-12-09T06:16:23.727+00:00

    @JAYLON LIU , based on my research, the Microsoft doc StandardPrintController.OnStartPage(PrintDocument, PrintPageEventArgs) Method has the following remarks.

    OnStartPage is called immediately before PrintDocument raises the PrintPage event.

    OnStartPrint creates the Graphics object used in printing. After OnStartPrint is called, the OnStartPage method sets the Graphics object to a graphic of a single page. The OnEndPage method clears the Graphics object, while the OnEndPrint method deallocates the object.

    From the above description, we can know the following factors can affect the performace.

    First, If the Graphics is too large, it will spend more time on creating the Graphics object and clearing the Graphics objects.

    Second, If there are many pages, it will also occupy many time because it needs to set the Graphics object to a graphic of a single page. It means that it will be in a loop.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.