Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't generate on a second request #174

Open
eliseumade opened this issue May 15, 2023 · 4 comments
Open

I can't generate on a second request #174

eliseumade opened this issue May 15, 2023 · 4 comments

Comments

@eliseumade
Copy link

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?

@foxlovei
Copy link

foxlovei commented Jun 7, 2023

how about this
#119

@thanhy123zzz
Copy link

public void ConfigureServices(IServiceCollection services)
{
// Add converter to DI
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
}
i think, this is your issues

@yozawiratama
Copy link

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

@bindalf
Copy link

bindalf commented Sep 2, 2024

same on maui windows app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants