0

I am using the Ghostscript in my C# dot.net core 6 azure function to convert pdf documents into png images, which works well in the local environment. However, when I tried to deploy it to Azure from my VS Code and test it, spotted that pdfs are not converted into png images. Looking into logs, I see the following error:

An error occurred during PDF to PNG conversion: An error occurred trying to start process './ghostscript/10.01.2/bin/gs' with working directory '/'. No such file or directory

Here is the relevant part of the code:

                var ghostscriptArgs = $"-q -dQUIET -dBATCH -dNOPAUSE -sDEVICE=pngalpha -r150 -sOutputFile=\"{tempDirectory}/output-%03d.png\" \"{tempFilePath}\"";
            var ghostscriptProcessInfo = new ProcessStartInfo
            {
                FileName = "./ghostscript/10.01.2/bin/gs",
                Arguments = ghostscriptArgs,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };

Here is the folder with ghostscript, placed in the project root: enter image description here

And here is the project file: enter image description here

Any idea where I am making a mistake? Thanks.

Miles
  • 29
  • 4
  • Does Azure Functions actually let you run arbitrary applications? I would suggest Ghoscript.NET but I think that uses a native DLL under the hood, which prob doesn't work either. – Charlieface Jul 18 '23 at 00:42
  • 1
    Solved. Containerised my application using Docker and it runs properly. – Miles Jul 18 '23 at 22:23

0 Answers0