Closed sajermann closed 3 years ago
It seems that you're instantiating the Converter two times, try to remove one of them and also make sure your ExecuteAsync is actually called.
I change:
My Worker.cs
public class Worker : BackgroundService
{
private readonly IConverter _converter;
public Worker(IConverter converter)
{
_converter = converter;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var doc = new HtmlToPdfDocument()
{
GlobalSettings = {
ColorMode = ColorMode.Color,
Orientation = Orientation.Portrait,
PaperSize = PaperKind.A4,
Margins = new MarginSettings() { Top = 10 },
Out = $"C:\\Users\\b.sajermann.da.silva\\Desktop\\test.pdf",
},
Objects = {
new ObjectSettings()
{
HtmlContent = @"<b>Lorem</b><div style='display:none'>bruno</div> ",
},
}
};
_converter.Convert(doc);
Console.WriteLine("Hello World!");
Console.ReadKey();
}
}
And the same error occurs...
Are you sure those just aren't warnings? Do you get an exception? Try to compare with the samples.
Yes, don't have exception, only print this errors in console and don't generate pdf...
But thanks for your attention, I try other solutions;
Thank's very much!
Since the message results in no PDF being generated, the ticket should not have been closed!
Since the message results in no PDF being generated, the ticket should not have been closed!
It was most likely because the OP created a new instance of the SynchronizedConverter
each time, or a missing external dependency. The samples in this project show how it's supposed to be used.
Hi, I am having trouble with implantation with Work Service
My Program.cs
My Worker.cs
Error in Console:
I've already tested it with and without [STAThread]
Thanks!