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