1

I want to use Ghostscript managed library in .NET C#. Does this needs Ghostscript to installed on the machine.

Cant we include this gsdll32.dll in my test application as reference to remove this dependency?

Shubh
  • 19
  • 6

3 Answers3

1

Yes, I use this code to call the DLL and not be forced to install ghostscript (works on x86 and x64 machines):

const string DLL_32BITS = "gsdll32.dll";
const string DLL_64BITS = "gsdll64.dll";

//select DLL based on arch
string NomeGhostscriptDLL;
if (Environment.Is64BitProcess)
{
    NomeGhostscriptDLL = DLL_64BITS;
}
else
{
    NomeGhostscriptDLL = DLL_32BITS;
}

GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(NomeGhostscriptDLL);

using (var rasterizer = new GhostscriptRasterizer())
{
    rasterizer.Open(e.FullPath, gvi, true);

    and so on...

P.S.: Remember to copy both dll's to output directory

Gustavo F
  • 2,071
  • 13
  • 23
  • What is the line "rasterizer.Open" meant to do? I am also unsure what "e.FullPath" is for. – abdullahalali Jul 27 '22 at 07:42
  • @abdullahalali e.FullPath it's the pdf input file. For more information, please read the official docs: https://github.com/jhabjan/Ghostscript.NET/blob/master/Ghostscript.NET.Samples/Samples/RasterizerSample1.cs – Gustavo F Jul 28 '22 at 13:08
  • For production environment, how do I make sure the gsdll32 dll file is on the end user's machine? During development, I have the dll file in my bin\Debug folder, and that folder is my build output path – abdullahalali Aug 02 '22 at 08:29
  • Just add the gsdll32 in include files: https://stackoverflow.com/questions/16785369/how-to-include-other-files-to-the-output-directory-in-c-sharp-upon-build – Gustavo F Aug 03 '22 at 13:26
0

Yes you can bypass installing GhostScript. You can put gs32.dll or gs64.dll and everywhere but you should add HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript\9.21 registry key:

  • GS_DLL Path to your gs32.dll file
  • GS_LIB path to your Library = this is Libraries\GS\Fonts from your setup.

It is better install with setup, copy usual files, then change registry and uninstall. Of course by uninstalling you will lose your registry entries (just rename before)

Emin Hasanov
  • 1,299
  • 1
  • 13
  • 29
0

If you are including Ghostscript as part of your application you must abide by the terms of the AGPL. This means your own application must be AGPL licenced, or you must seek a commercial licence.

If you supply the Ghostscript libraries, without including the licence and details of where the Ghostscript source can be obtained, then you are in violation of the licence.

And yes, this covers just the DLLs. Shubh it sounds to me (since you talk about 'your application') like you are violating the licence, unless your application is also licenced under the AGPL of course.

KenS
  • 30,202
  • 3
  • 34
  • 51