Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Use system wide installed wkhtmltopdf #27

Open
joa77 opened this issue Aug 27, 2020 · 6 comments · Fixed by #32
Open

Use system wide installed wkhtmltopdf #27

joa77 opened this issue Aug 27, 2020 · 6 comments · Fixed by #32

Comments

@joa77
Copy link

joa77 commented Aug 27, 2020

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

@fpanaccia
Copy link
Owner

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");

@joa77
Copy link
Author

joa77 commented Aug 27, 2020

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

@fpanaccia
Copy link
Owner

Yeah, i forgot about those lines, the online way i think it could work is with a few modifications

@fpanaccia
Copy link
Owner

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

@gurustron
Copy link
Contributor

gurustron commented Sep 8, 2020

@fpanaccia

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.

@fpanaccia
Copy link
Owner

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

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

Successfully merging a pull request may close this issue.

3 participants