HakanL / WkHtmlToPdf-DotNet

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
GNU Lesser General Public License v3.0
367 stars 66 forks source link

Previous image is mistakenly inserted into the PDF of the next conversion #68

Closed hauffautomation closed 2 years ago

hauffautomation commented 2 years ago

It happens again and again that the first HTML (locally saved HTML) is correctly converted to PDF (including images). With the next HTML file then not the correct image is inserted, but one from the previous HTML file. My question is it possible to reset WkHtmlToPdf completely after each conversion? It seems to me that there is some cache in WkHtmlToPdf that causes this.

HakanL commented 2 years ago

Make sure you use it correctly (global SynchronizedConverter), see the examples and the other issues reported here.

HakanL commented 2 years ago

See #27

hauffautomation commented 2 years ago

Okey, thanks for your reply.

Also make sure you're not creating a new converter every time, you should only create it once per process. See the ASP.NET example.

Yes I did that. Since then it also runs much better. However, I still have (from time to time) the problem that a wrong image is inserted.

Is it possible to send you two html files for testing?

hauffautomation commented 2 years ago

Since I couldn't think of anything else, I replaced the image link in the HTML with BASE64 Image. The first test runs were promising

HakanL commented 2 years ago

Could be an issue with whatever is providing the images. Also please remember that this project is just a wrapper of wkthmltopdf that does the actual work, no processing of the HTML is done by this project.