7

I'm in the process of moving some on-premise app to Azure and struggling with once aspect - GhostScript. We use GhostScript to convert PDF's to multi page TIFF's. At present this is deployed in an Azure VM, but it seems like a WebApp and WebJob would be a better fit - from a management point of view. In all of my testing I've been unable to get a job to run the GhostScript exe.

Has anyone been able to run GhostScript or any third party exe in a WebJob?

I have tried packaging the GhostScript exe, lib and dll into a ZIP file and then unzip to Path.GetTempPath() and then using a new System.Diagnostics.Process to run the exe with the required parameters - this didn't work - the process refused to start with an exit code of -1073741819.

Any help or suggestions would be appreciated.

markpirvine
  • 1,485
  • 1
  • 23
  • 54
  • AFAIK GhostScript requires an installation or some manual setup (registry and/or environment variables). It also create temp files during pdf processing. And, worst, WebJobs run under IIS control that imposes other security rescrictions. So, IMHO, continue using a VM. – Fabrizio Accatino Apr 07 '15 at 06:00
  • @FabrizioAccatino, thanks for taking the time to reply. I've just been able to successfully convert a pdf to tiff using a webjob. I had included the GhostScript files in a subdirectory - I found this post (from an unrelated search) http://stackoverflow.com/questions/26840167/deploy-subfolders-for-azure-webjob, there is a bug which prevent subfolders being publish in VS. Once I uploaded the content via FTP everything worked – markpirvine Apr 07 '15 at 07:49
  • Very interesting. I thought it cannot work. :) But, again, I don't think webjobs are the right environment where to run ghostscript. Think about fonts: how can you install them? If your source pdf has not embedded font, you need the font present on the server for a good conversion from pdf to tiff. – Fabrizio Accatino Apr 07 '15 at 12:40

1 Answers1

3

We got it to work here: Converting PDFs to Multipage Tiff files Using Azure WebJobs. The key was putting the Ghostscript assemblies in the root of the project and setting "Copy always". This is what allows them to be pushed to the Azure server, and to end up in the correct place, when you publish the project.

Also, we needed to download the file to be processed by Ghostscript to the local Azure WebJob temp directory. This is discovered by using the following code:

Environment.GetEnvironmentVariable("WEBJOBS_PATH");
Michael Washington
  • 2,744
  • 20
  • 29
  • I'm hoping there's a way to add a step to my CI pipeline that will install GS on an Azure build agent. I already have my code working and don't want to have to re-point it at a local version of GS.. but this is useful to know what's possible. Thank you for posting your discovery – bkwdesign Oct 30 '20 at 03:01