EvoPdf Next for .NET is a library that can be integrated into applications running in Azure Container Apps to create and process PDF documents.
You can create PDF documents, convert HTML, Word, Excel, RTF and Markdown documents to PDF, extract text and images from existing PDF documents, perform text search operations on PDF documents and convert PDF pages to images.
EvoPdf Next for .NET runs in Azure Container Apps applications deployed from a Linux container image built on the ASP.NET Core runtime images. The image contains the application, the library runtime and the system packages required by the HTML to PDF Converter, so the application needs no setup when it starts. The other components don't require any additional packages.
The library targets .NET Standard 2.0, making it usable in any .NET Core application that supports this standard.
Create a new ASP.NET Core project in Visual Studio and use the NuGet Package Manager to add a reference to the EvoPdf.Next.Linux NuGet metapackage which will install all the library components.
To install only specific components of the EvoPdf Next library you can add references to the corresponding NuGet packages. You can find more details about the available packages in the Getting Started on Linux documentation section.
After installing the package, add the using EvoPdf.Next; directive at the top of your source files to access the EvoPdf Next API.
Publish the application for Linux:
dotnet publish -c Release -r linux-x64 --self-contained false -o publishCreate the Dockerfile below next to the publish folder and replace MyApp.dll with the name of your application. It starts from the ASP.NET Core runtime image, installs the system packages required by the HTML to PDF Converter, copies the publish folder and gives execute permission to the runtime files, which a publish folder created on Windows does not keep. The application listens on port 8080.
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Install the packages required by the HTML to PDF Converter
RUN apt-get update && \
apt-get install -y \
libnss3 \
libatk-bridge2.0-0 \
libcairo2 \
libpango-1.0-0 && \
rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Copy the published application
COPY publish/ .
# Ensure execute permissions for the HTML to PDF Converter runtime
RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_loadhtml
# Ensure execute permissions for the PDF Processor runtime
RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_pdfprocessor
# Listen on port 8080
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
# Start the application
ENTRYPOINT ["dotnet", "MyApp.dll"]For an application that targets .NET 8, start from the mcr.microsoft.com/dotnet/aspnet:8.0 image; the packages are the same. Build the image for the x86_64 architecture:
docker build --platform linux/amd64 -t pdf-app .Container Apps loads the image from a container registry. In the Azure portal open Cloud Shell in Bash mode (it is already signed in to your account) and create a resource group and a registry. The registry name must be unique in Azure; replace myregistry with your own name.
az group create --name pdf-app-rg --location westeurope
az acr create --resource-group pdf-app-rg --name myregistry --sku Basic --admin-enabled true
az acr credential show --name myregistry --query "passwords[0].value" -o tsvThe last command shows the password of the registry. On the computer where the image was built, sign Docker in to the registry with the registry name as user name and push the image:
docker login myregistry.azurecr.io -u myregistry
docker tag pdf-app myregistry.azurecr.io/pdf-app:1
docker push myregistry.azurecr.io/pdf-app:1In Cloud Shell, add the Container Apps extension of the Azure CLI, register the services once per subscription, create the environment and the application. Creating the environment takes a few minutes; the applications created later in the same environment start in less than a minute.
az extension add --name containerapp --upgrade --yes
az provider register --namespace Microsoft.App --wait
az provider register --namespace Microsoft.OperationalInsights --wait
az containerapp env create --name pdf-env --resource-group pdf-app-rg --location westeurope
az containerapp create --name pdf-app --resource-group pdf-app-rg --environment pdf-env \
--image myregistry.azurecr.io/pdf-app:1 --registry-server myregistry.azurecr.io \
--registry-username myregistry \
--registry-password "$(az acr credential show --name myregistry --query 'passwords[0].value' -o tsv)" \
--ingress external --target-port 8080 --cpu 2 --memory 4Gi --min-replicas 1 --max-replicas 3 \
--query properties.configuration.ingress.fqdn -o tsv--target-port 8080: the port the application listens on, set in the Dockerfile.
--cpu 2 --memory 4Gi: HTML to PDF conversion can be resource-intensive, depending on the complexity of the content. 2 vCPUs and 4 GiB of memory per replica are the minimum we recommend.
--min-replicas 1: keeps one replica running, so a request never waits for an application to start. With 0 the application scales to zero when idle and the first request after a pause starts it again.
--max-replicas 3: the number of replicas Container Apps can add when the requests grow.
The create command ends with the address of the application; open it with https://. To deploy a new version, push the image with a new tag and run az containerapp update --name pdf-app --resource-group pdf-app-rg --image myregistry.azurecr.io/pdf-app:2.
As a reference, in the West Europe region a replica with 2 vCPUs and 4 GiB of memory converted a two-page HTML document 6 times per second with four parallel conversions.
You can follow the same steps to publish the EvoPdf Next ASP.NET demo application, from the EvoPdf_Next_AspNetDemo_Linux_net10.0.csproj project, with EvoPdf_Next_AspNetDemo_Linux_net10.0.dll in the Dockerfile.
The output and the exceptions of the application are shown in the Log stream page of the application in the Azure portal, or with the commands below in Cloud Shell. The system log shows the events of the platform, such as the image pulled from the registry and the container started or stopped.
az containerapp logs show --name pdf-app --resource-group pdf-app-rg --type console --tail 100
az containerapp logs show --name pdf-app --resource-group pdf-app-rg --type system --tail 50If the application does not respond and the system log shows the container restarted, check that the --target-port value matches the port in the ASPNETCORE_URLS variable of the Dockerfile.