I have been using PDFsharp to merge 2 PDFs in one document and then print it. This seems to be working fine most of the time, however whenever it is under heavy load (even making 4 simultaneous POST requests) some of the printed pages are blank. Is this is a known issue with PDFsharp and if it is, does anyone have the fix?
What am I testing?
I am trying to print 3 pages in duplex as part of 1 request and have been testing 4 simultaneous calls. So, altogether I would have 12 pages.
Result
I am getting half of the pages blank (so 5-6 pages).
Another test I did – Previously I did another test where I made 100 requests (so printed 100 * 3 = 300 pages) and all the pages came out fine. However, with this I was making 1 request, waiting for it to finish and once it finished only then made another requests. This seems to suggest that PDFsharp is not able to print the documents correctly when used in asynchronous manner. However, as part of my application I have to make asynchronous requests so waiting for 1 request to finish is not an option.
PS - I am using latest PDFsharp version 1.32
The generated (concatenated) PDF is fine, there are no blank pages in it. It is only when they get printed then I get some blank pages.
PDFsharp does not print PDF files at all. So you cannot blame PDFsharp if printing fails under heavy load.
AFAIK PDFsharp is not thread-safe (like most libraries). If you manipulate several PDF files at the same time, you have to use different threads - one thread for each PDF file.
Most likely you use Adobe Reader to print the PDF files. You may have to serialize calls to Adobe Reader.