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

Seems like you need to have Ghostscript installed #1

Closed
skttl opened this issue Feb 6, 2017 · 8 comments
Closed

Seems like you need to have Ghostscript installed #1

skttl opened this issue Feb 6, 2017 · 8 comments

Comments

@skttl
Copy link

skttl commented Feb 6, 2017

I kept getting messages stating that Ghostscript couldn't find the installed version, so googled around a bit, and found a workaround, for when you don't have GS installed (http://ghostscriptnet.codeplex.com/discussions/465418).

I then implemented it in PdfRasterizer like this, and now it works like a charm. Not sure if this is a good way to go though.

        public PdfRasterizer(int xDpi = 96, int yDpi = 96)
        {
            _desiredXDpi = xDpi;
            _desiredYDpi = yDpi;

            _lastInstalledVersion = new GhostscriptVersionInfo(new System.Version(0, 0, 0), HttpContext.Current.Server.MapPath("~/bin/gsdll32.dll"), string.Empty, GhostscriptLicense.GPL);

            _rasterizer = new GhostscriptRasterizer();
        }
@dampee
Copy link
Owner

dampee commented Feb 8, 2017

Hi,
I have not added Ghostscript because I do not know if I am allowed if you take licensing into account. The readme explains that you can also do a copy/paste deploy of the ghostscript DLL's.
If you add the 32 AND the 64 bit dll, you should be good to go. I guess you did not have both dll's in your bin directory.
Kind regards
Damiaan

@tomvanenckevort
Copy link
Contributor

Hi,

We've run into the same issue here. We have got both the gsdll32.dll and gsdll64.dll in the bin folder, but it doesn't work (same error as @skttl).
If you look at the source code for the GetLastInstalledVersion method that you call in the PdfRasterizer, you can see it calls GetInstalledVersions which interrogates the registry to find the installed versions: https://github.com/jhabjan/Ghostscript.NET/blob/master/Ghostscript.NET/GhostscriptVersionInfo.cs#L156

This won't work if you haven't got GhostScript installed on the server.
I think @skttl's suggestion from above would be good (with an additional check to load the correct DLL if it's a 64-bit environment), and shouldn't affect any license issues.

I'm thinking something like:

public PdfRasterizer(int xDpi = 96, int yDpi = 96)
{
    _desiredXDpi = xDpi;
    _desiredYDpi = yDpi;

    _lastInstalledVersion = new GhostscriptVersionInfo(new System.Version(0, 0, 0), HttpContext.Current.Server.MapPath(Environment.Is64BitProcess ? "~/bin/gsdll64.dll" : "~/bin/gsdll32.dll"), string.Empty, GhostscriptLicense.GPL | GhostscriptLicense.AFPL);

    _rasterizer = new GhostscriptRasterizer();
}

(obviously that code could be a bit tidier :))

@dampee
Copy link
Owner

dampee commented Apr 24, 2017

Do one of you have time to do a quick pull request?

@dampee
Copy link
Owner

dampee commented Apr 24, 2017

Nevermind... just found #2

@dampee
Copy link
Owner

dampee commented Apr 24, 2017

Merged and pushed it online. Hope it works - did not test.

@tomvanenckevort
Copy link
Contributor

@dampee We've tested the new version here and it's working fine now. So from my point of view this issue has been solved. But I guess it would be good if @skttl can confirm it works for him as well :)

@dampee
Copy link
Owner

dampee commented Apr 25, 2017

In the meantime I have done some additional testing and it solved an issue for a side project :-) So 👍 for both of you. Find me at Codegarden (if you go). I'll buy you both a beer. ;-)

@dampee dampee closed this as completed Apr 25, 2017
@skttl
Copy link
Author

skttl commented Sep 1, 2017

A bit late to the party. It works on my local machine, but not on the website (hosted on Azure web apps).

I get "An error occured when call to 'gsapi_new_instance' is made: -100". Not sure if related.

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

3 participants