Closed ghost closed 6 years ago
You must declare SynchronizedConverter as singleton. Example with DI.
Thanks for the quick reply! Did the DI thing and it's working now, thx :)
You might want to reply to maztt on this page: https://stackoverflow.com/questions/39364687/export-html-to-pdf-in-asp-net-core
I don't have enough reputation.
this solution didn't worked for me. I have declared singleton but still it stops at line var bytes = converter.Convert(doc); Please suggest.
Remove this 'var converter = new SynchronizedConverter(new PdfTools());' and just inject 'IConverter' in your service. I try and this approach is working, after all, we already register the converter, we don`t need to create an instance with 'new' keyword.
// startup.cs
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
// service class
private readonly IConverter _converter;
public PdfService(IConverter converter)
{
_converter = converter;
}
^ That fixed my problem. Thanks guys!
I'm using this on Windows 10 with a .Net core 2 web api.
The first call works fine, but subsequent calls hang. Any ideas?