Use system wide installed wkhtmltopdf
Opened this issue · 6 comments
Is there any chance to use a system wide installed version of wkhtmltopdf?
Because my hoster already deploys an up to date version on theirs servers. I have multiple services which use pdf rendering with wkhtmltopdf and it would be very nice to use the version provided by the system, instead having every app it's own binary
Hi!, i think you could, without any modification in the library, you could do something like this in the startup
services.AddWkhtmltopdf("PATH_TO_SYSTEM_WIDE_VERSION");
Unfortunately the WkhtmlDriver
class hardcodes an operating system directory to the wkhtmltopdf
path.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
rotativaLocation = Path.Combine(wkhtmlPath, "Windows", "wkhtmltopdf.exe");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
rotativaLocation = Path.Combine(wkhtmlPath, "Mac", "wkhtmltopdf");
}
else
{
rotativaLocation = Path.Combine(wkhtmlPath, "Linux", "wkhtmltopdf");
}
For example, it is not possible for the binary file to be located under /usr/local/bin/wkhtmltopdf
Yeah, i forgot about those lines, the online way i think it could work is with a few modifications
i think im gonna add a parameter in the setup like "usesystemwide" or something like that....and invoke wkhtmltopdf, the only catch is that the path to wkhtmltopdf will have to be added to the env variable PATH
Also there are line in AddWkhtmltopdf
: RotativaPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, wkhtmltopdfRelativePath);
This can be worked around with setting static variable after the call, but then there are lines as OP described.
I'm planning to implement such feature in my fork. We can collaborate on that. I think user should be able to provide full path to executable, also I suggest removing the static path from settings.
Hi @gurustron! yes, i had planned to do that in the weekend, i have little time available as this moment, if you have the time, please, be my guest