Comments (6)
Hi @HakanL ,
We've occurred with the same problem in integration tests and solved it via adding pdftools to DI container.
Please have a look in our code
public void ConfigureServices(IServiceCollection services)
{
// let's register pdf tools for correct ending the chrome process
// when application shutting down
services.AddSingleton(typeof(ITools), typeof(PdfTools);
// this scenario apply only in multi-thread scenario like in a webserver
// see also: https://github.com/rdvojmoc/DinkToPdf#dependency-injection
services.AddSingleton(typeof(IConverter), typeof(SynchronizedConverter);
}
If it looks normal I will prepare pull request to the documentation
from wkhtmltopdf-dotnet.
@sflusov Yeah, that's a workaround (to always hold a reference to it), but the issue is if you want to do a teardown then it's not working.
from wkhtmltopdf-dotnet.
We have ~1.5k integration tests which use WebApplicationFactory (TestServer) and there is no problem run it again and again.
Maybe you lost dispose method in the end of test collection.
So If you provide example of code I will try to help you
from wkhtmltopdf-dotnet.
It's not a problem if you don't try to dispose (which is typically the setup with DI), but this bug was raised because it didn't work to tear it down. We would probably need to add a separate unit test to the project to test repeated setup/teardown, I don't think there is one currently, PRs welcome.
from wkhtmltopdf-dotnet.
Doing:
using(var converter = new SynchronizedConverter(new PdfTools())){
... do
}
Works the first time, but crashes the application on subsequent calls to this method.
This is solved by keeping one copy of SynchronizedConverter
as a static variable, but rebuilding the site fails with the error:
The process cannot access the file '\bin\runtimes\win-x64\native\wkhtmltox.dll' because it is being used by another process. The file is locked by: "w3wp.exe (16856)"
Docs need to be clearer on how to use SynchronizedConverter and it looks like a bit of a showstopper bug for us that something isn't being disposed properly.
from wkhtmltopdf-dotnet.
@TomGullen You should always just have a singleton/static instance of the SynchronizedConverter when using this project. I assume the teardown issue has something to do with the native library, but more investigation is needed. The examples in here use the SynchronizedConverter, but feel free to submit PR for how the docs can be improved.
from wkhtmltopdf-dotnet.
Related Issues (20)
- Table of content styling HOT 2
- Exclude runtimes folder from publish HOT 2
- libwkhtmltox using produceForms html form to pdf form does not work HOT 2
- Local file access HOT 1
- Gmail is detecting pdf generated by WkHtmlToPdf-DotNet as malware HOT 1
- creating pdf with .net6 in aws lambda HOT 4
- Not able to generate report once deployed to Kubernates HOT 1
- Execution time increases under load HOT 1
- I didn't use dependency injection. Using static creation would cause the thread to get stuck and new requests to keep getting stuck HOT 22
- % in the href attribute are still encoded to %25 HOT 2
- Not reading settings on alpine HOT 2
- HTML tags removed HOT 3
- Reporting a vulnerability HOT 1
- In Linux CentOS 7, there was an error: Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported. HOT 3
- Memory overflow HOT 2
- The wkhtmltopdf project that is used, is no longer maintained HOT 3
- Display flex is not working HOT 1
- Unable to load native library - Windows 10/11 HOT 16
- Add ability to process pdf generation on multiple threads HOT 1
- How can I set html code with css in header HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wkhtmltopdf-dotnet.