How to add GhostScript NuGet package to Azure Function App?

HEAT 1 Reputation point
2022-12-03T17:12:29.017+00:00

I am trying to create an Azure Function App that merges a set of documents into a single PDF. I also need to convert some images to PDF and include those in the merged output file.

I have a working Power Automate Desktop flow that uses PowerShell scripts to run ImageMagick to convert images to PDF and GhostScript to merge all the PDF documents to a single PDF output file. I want to port my PAD flow and PowerShell scripts to an Azure Function App to hopefully speed up the runtime and response time to a Power Apps canvas app.

A bonus goal would be to fill .docx templates with data and convert them to PDFs first, then run the merge scripts and output the filled and merged document for consumption by Power Apps.

Let me simplify my question by focusing specifically on just the GhostScript aspect of this project. My issue is that when I try to run dotnet add package GhostScript.NET --version 1.2.3 I get the following output:

warn : NU1701: Package 'Ghostscript.NET 1.2.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.

I am using Azure Functions runtime version ~4 and .NET version 6.0.403. Here is what my .csproj looks like:

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <AzureFunctionsVersion>v4</AzureFunctionsVersion> </PropertyGroup> <ItemGroup> <PackageReference Include="GhostScript.NET" Version="1.2.3" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" /> </ItemGroup> <ItemGroup> <None Update="host.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> <None Update="local.settings.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToPublishDirectory>Never</CopyToPublishDirectory> </None> </ItemGroup> </Project>

In my 'HttpTrigger1.cs' file, when importing GhostScript.NET with using GhostScript.NET; I get the following error:

The type or namespace name 'GhostScript' could not be found (are you missing a using directive or an assembly reference?)

Any ideas how I can correct these issues? I'm using VSCode to edit the project and GitHub for continuous deployment to the function app.

Your help is greatly appreciated!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-12-03T18:29:26.317+00:00

    The GhostScript.NET nuget package does not support .net core. The project appears to be dead. You could clone and update

    https://github.com/jhabjan/Ghostscript.NET

    Note: since this wrapper projects last update, the Ghostscript library has been rewritten.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.