DinkToPdf: Qt: Could not initialize OLE (error 80010106)
I’m working on a ASP.NET Core MVC app and I wanted to use DinkToPdf library to convert Html to PDF. I get this error in the console, when I first access a page that uses the IConverter from the services:
Qt: Could not initialize OLE (error 80010106)
I still get the PDF with no issues. I think the issue is somewhere around calling: new SynchronizedConverter(new PdfTools()) As I have it in the services as a singleton and only called the first time it’s accessed:
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 5
- Comments: 22
Commits related to this issue
- Update SynchronizedConverter.cs // This is to fix issue https://github.com/rdvojmoc/DinkToPdf/issues/119 — committed to BhangeeF16/DinkToPdf by BhangeeF16 2 years ago
I’ve just hit this problem too, in an Azure Isolated Functions host project.
I’m pretty sure this issue is due to the worker thread in
SynchronizedConverternot being STA mode. So I copied theSynchronizedConverterand made an STA version.Thanks, @distantcam it is work.
only notice for all, To access the
Converterclass, you must inject it, not create a new instance.HI @dqmarkmagaoay , this library is no longer maintained, from my stressed test output, it can serve around 1.5K request/per hour. If it won’t fit your need, you need to use PDFSharp, or headless pdf, or a paid library.
@distantcam provided the solution. It works fine @Workaholic01. Those who may be checking this page in search of a solution, implement the solution by @distantcam. works for dotnet 6 … @distantcam Thanks for the solution
I’ve not written an Azure function but if you’re using wkhtmltopdf that implies you can at least load a DLL.
An exe might not work directly in an Azure function but what stops you from using more appropriate hosting to implement HTML to PDF as a web service and using it that way? Generation time is a few hundred ms for single page documents.
If that’s not good enough, Chromium is open source. Contribute a direct API and make yourself very popular.