DinkToPdf
DinkToPdf copied to clipboard
I can't generate on a second request
Hello, I'm using the lib in a project, but I can generate the normal pdf in the first request, but if I make a second request, it doesn't call, it just waits, so I can get another request, I have to rebuild the api, does anyone know how to solve this?
how about this https://github.com/rdvojmoc/DinkToPdf/issues/119
public void ConfigureServices(IServiceCollection services) { // Add converter to DI services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools())); } i think, this is your issues
I'm having the same issue, has anyone solved this problem?
I already add this code
builder.Services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
and also I already add load library manually
string libraryPath = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Load .dll for Windows
libraryPath = "libwkhtmltox.dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// Load .so for Linux
libraryPath = "libwkhtmltox.so";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// Load .dylib for macOS
libraryPath = "libwkhtmltox.sylib";
}
var loadContext = new CustomAssemblyLoadContext();
var fullpath = Path.Combine(Directory.GetCurrentDirectory(), libraryPath);
IntPtr libraryHandle = loadContext.LoadUnmanagedLibrary(Path.Combine(Directory.GetCurrentDirectory(), libraryPath));
// Pastikan library berhasil dimuat
if (libraryHandle == IntPtr.Zero)
{
Console.WriteLine("Failed to load the library.");
return;
}
Console.WriteLine("Library loaded successfully.");
var builder = WebApplication.CreateBuilder(args);
but the problem still same, the second request response properly, I suspect libwkhtmltox
is still stuck in the process, as we know we use external library here, and it do not managed properly by dotnet core.
So is there anyone already solve this problem?
btw I user docker linux here