Hi @Shyam Butani , thank you for reaching out on Microsoft Q&A!
According to this documentation:
When an application has finished printing, it deletes the printer DC by calling the DeleteDC function. An application must delete (rather than release) a printer DC; the ReleaseDC function fails when an application attempts to use it to release a printer DC.
And in this document:
When you no longer need the DC, call the DeleteDC function.
These mean that you have to delete the printer DC after you create and finish your job.
Because of this, the supported workflow for printing is like this way based on this document:
-
CreateDC
-
StartDoc
→StartPage
→ [drawing] →EndPage
→EndDoc
-
DeleteDC
The documentation doesn’t say how many times you can call StartDoc
and EndDoc
in one workflow. However, the StartDocA function document mentions that:
Applications should call the StartDoc function immediately before beginning a print job. Using this function ensures that multipage documents are not interspersed with other print jobs.
Based on this doc, I believe that each print job should have its own lifecycle, starting with CreateDC
and ending with DeleteDC
. It’s likely the safest way to keep documents separate and avoid mixing pages between jobs.
Overall, I don't think this is required by any official documentations. However, following this pattern is a good practice to ensure reliable printing.
I'm sorry for the misread before, I hope this edited explanation will help you fully understand this problem. Thank you!