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!