Exception when multiple requests sent to ToPDF

Q:

We have developed a web service that uses PDFNET SDK to Convert various file formats (doc, docx, xls, xslx, HTML, MHT) to PDF format. We are using ToPDF () method of PDFNET SDK for conversion implementation.
While doing a performance/load test on HTML to PDF conversion, we encountered an issue where in PDFNET.dll is throwing an exception as below when multiple requests sent to the web service in parallel. If the same multiple requests sent one after another sequentially the web service is behaving perfectly file. Interestingly the same code is working fine for Word to PDF conversion even when we are sending multiple requests simultaneously.

Please let us know if you need more details or information to understand the issue correctly.

Exception:
Message: An error occurred while converting the file.
Detailed error:
Unable to synchronize with other PDFNet ToPdf instances, Windows System error.
Conditional expression: false
Filename : Convert.cpp
Function : trn::PDF::Convert::ToPdf
Linenumber : 1693

A:

what is happening is that most (or perhaps all non-html) conversions are going through MS Office Interop, while the HTML conversion is going through other means. This other path requires the use of the windows registries and currently this needs to be synchronized across all threads and processes (so only one thread, or process, is reading and writing at one time). There is a timer, so the exception only occurs if a thread or process has been deemed to be waiting too long.

Perhaps you could separate the html conversions from the rest, and serialize only the html conversions. This would maximize your throughput.

Please note that we provide another means of HTML to PDF conversion, through the HTML2PDF add-on, but that this requires an additional license. You can of course try it out in demo mode. The reason I mention this alternative is that it provides true parallelism, and is multi-thread/process safe. See http://www.pdftron.com/pdfnet/samplecode/Html2PdfTest.cs

Q:

Other than multithread support/Thread safety mentioned earlier, what are the other differences between using ToPDF (virtual printer) and HTML2PDF module to convert HTML to PDF? Especially is there any difference in the quality of conversion?

I remember we had tried using HTML2PDF, but we found the converted PDF did not had few images/logos that were associated with the source html file.

We thought since ToPDF() uses Virtual printer and the conversion quality would be much better than HTMLToPDF.

Please let us know which is the better option considering the quality of conversion?

On another thought does the quality of conversion depends on the default browser associated with HTML file?

A:

The HTML2PDF module uses webkit, so you should get a similar output as you would see with other webkit based browsers such as Chrome and Safari. Though the HTML2PDF webkit version is older than what the browsers use.

On the other hand ToPDF relies on external program to print, so if you right click an html file on your computer (or whichever machine is doing conversion) and select the ‘print’ option from the context menu you can see which application is being used in the conversion process (which may very well be a browser).

As for better output that is up to you, as there is some ambiguity between converting from reflowable html to fixed pdf (especially when to break content, so text, images, etc are not cut off at the end of a pdf page). One bonus of HTML2PDF is that it provides lots of customization options, including creating tables of contents. But since you’re using ToPDF then I gather this is not as important for you.

This posting provides more details on using the virtual printer.
https://groups.google.com/forum/?fromgroups#!searchin/pdfnet-sdk/virtual$20printer/pdfnet-sdk/ovStpU-HGYk/s-PMo7sGMT8J