EvoPdf Next – HTML to PDF Converter for .NET
HTML to PDF in AWS · .NET

Convert HTML to PDF in AWS: Elastic Beanstalk, Lambda and ECS

EvoPdf Next renders HTML to PDF inside your Elastic Beanstalk application and inside Lambda functions. On Windows Server you publish and convert. On Amazon Linux 2023 a configuration file in the application bundle prepares every instance at deployment, so the instances added by autoscaling convert from their first request. In Lambda the function ships as a container image with the runtime and the fonts inside. In ECS on Fargate every task starts from the image of your application, ready to convert.

Version 14.86.0. Building EVO PDF libraries since 2010. Evaluate without registration; the demo output is watermarked until you set a license key. Perpetual licenses from 450 USD, or 1200 with redistribution and unlimited servers. Every license covers any number of developers.

Elastic Beanstalk guides · Lambda guide · ECS guide · Samples and demos on GitHub · AI agent skills

ConsoleCLI
dotnet add package EvoPdf.Next.HtmlToPdf.Linux

Amazon Linux 2023 on x86_64; for Graviton instances reference EvoPdf.Next.HtmlToPdf.Linux.Arm64 and for Windows Server EvoPdf.Next.HtmlToPdf.Windows; the code is identical

.ebextensions/evopdf.configYAML
# applied at every deployment, on every instance
packages:
  yum:
    nss: []
    at-spi2-atk: []
    cairo: []
    pango: []
    dejavu-sans-fonts: []
    dejavu-serif-fonts: []
    dejavu-sans-mono-fonts: []
files:
  "/etc/fonts/local.conf":
    mode: "000644"
    content: |
      <fontconfig>
        <alias>
          <family>sans-serif</family>
          <prefer><family>DejaVu Sans</family></prefer>
        </alias>
      </fontconfig>
container_commands:
  01_evopdf_loadhtml:
    command: "chmod +x evopdf_runtimes/linux-x64/native/evopdf_loadhtml"
  02_evopdf_pdfprocessor:
    command: "chmod +x evopdf_runtimes/linux-x64/native/evopdf_pdfprocessor"
The whole Linux setup. Step-by-step guide →
  • Elastic Beanstalk on Amazon Linux 2023
  • Elastic Beanstalk on Windows Server
  • x86_64 and Graviton arm64 instances
  • Lambda functions on x86_64 and arm64
  • ECS on Fargate, EKS and other container hosts
  • .NET 10 and .NET 8
Linux and Windows

The same API on both Elastic Beanstalk platforms

The rendering engine is a Chromium build integrated with the library and it travels inside the NuGet package. Reference the package for your platform, publish, upload the bundle and convert. HTML to PDF is the component that asks for CPU and memory, so the instance type matters more than the platform: t3.medium is the smallest type we recommend.

Amazon Linux 2023

Reference EvoPdf.Next.Linux and add one configuration file to the project. Elastic Beanstalk runs it as root at every deployment: it installs four system packages and the DejaVu fonts, sets DejaVu Sans as the sans-serif font and gives execute permission to the runtime files. The other components need nothing extra.

  • t3.medium for development and testing, more memory for production volumes
  • x86_64 and Graviton arm64 instances

Windows Server

Reference EvoPdf.Next.Windows, publish and deploy with the standard Elastic Beanstalk manifest for ASP.NET Core. The 64-bit IIS application needs no configuration and nothing installed on the instance.

  • t3.medium at minimum, t3.large or higher in production
  • IIS 10.0 on Windows Server 2022 and 2025

EvoPdf Next HTML to PDF →

Amazon Linux 2023

Deploy to Elastic Beanstalk on Linux

Two folders in the root of the project carry the whole setup. Elastic Beanstalk reads them from the root of the application bundle and applies them to every instance it creates, including the ones added by autoscaling.

1. Configuration files

.ebextensions/evopdf.config installs the packages and sets the permissions, as shown above. .platform/nginx/conf.d/evopdf.conf raises the limits of the nginx proxy in front of the application, for long conversions and uploaded documents:

proxy_read_timeout 300;
client_max_body_size 50M;

Copy both folders to every publish from the project file:

<ItemGroup>
  <None Include=".ebextensions\**" CopyToPublishDirectory="PreserveNewest" />
  <None Include=".platform\**" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>

2. Publish, package, deploy

dotnet publish -c Release -r linux-x64 --self-contained false -o publish

Zip the content of the publish folder, with the two configuration folders at the root of the archive. In the Elastic Beanstalk console create a web server environment on the .NET platform for Linux with the branch running on 64bit Amazon Linux 2023 for your .NET version and upload the archive. Choose t3.medium or larger under Instance types.

No Procfile is needed: Elastic Beanstalk finds the application by its runtimeconfig.json file. New versions go up with Upload and deploy on the environment page.

Step-by-step guide →

Windows Server

Deploy to Elastic Beanstalk on Windows

Nothing to install on the instance. Publish for win-x64, zip the publish folder as site.zip and put it in the application bundle next to the deployment manifest that Elastic Beanstalk uses for ASP.NET Core applications. The AWS Toolkit for Visual Studio builds the same bundle for you.

aws-windows-deployment-manifest.jsonJSON
{
  "manifestVersion": 1,
  "deployments": {
    "aspNetCoreWeb": [
      {
        "name": "evopdf-app",
        "parameters": {
          "appBundle": "site.zip",
          "iisPath": "/",
          "iisWebSite": "Default Web Site"
        }
      }
    ]
  }
}
Platform .NET on Windows Server, IIS 10.0, t3.medium or larger. Windows guide →
AWS Lambda

Convert HTML to PDF in a Lambda function

A Lambda function packaged as a container image runs EvoPdf Next with nothing to set up at run time: the image built from the Lambda base image for .NET 10 carries the runtime, the system packages and the fonts. The function below returns the PDF for the page named in the query string, through a function URL or an API Gateway HTTP API.

DockerfileLambda .NET 10
FROM public.ecr.aws/lambda/dotnet:10

# packages for the converter and the DejaVu fonts
RUN dnf install -y nss at-spi2-atk cairo pango dejavu-sans-fonts \
    dejavu-serif-fonts dejavu-sans-mono-fonts && dnf clean all

# DejaVu Sans as the sans-serif font
RUN printf '<fontconfig><alias><family>sans-serif</family><prefer><family>DejaVu Sans</family></prefer></alias></fontconfig>' > /etc/fonts/local.conf

COPY publish/ ${LAMBDA_TASK_ROOT}
RUN chmod +x ${LAMBDA_TASK_ROOT}/evopdf_runtimes/linux-x64/native/evopdf_loadhtml

# the only writable folder of a function
ENV HOME=/tmp

CMD ["PdfFunction::PdfFunction.Function::FunctionHandler"]
The DejaVu fonts render the text of pages without web fonts. Lambda guide →

Publish, build, push, create

dotnet publish -c Release -r linux-x64 --self-contained false -o publish
docker build --platform linux/amd64 --provenance=false --sbom=false -t pdf-function .

Push the image to a private repository in Elastic Container Registry and create the function from it in the Lambda console, as a container image. A zip deployment is limited to 250 MB of code, which is less than the converter runtime, so the image is the packaging for this library.

For Graviton, reference EvoPdf.Next.HtmlToPdf.Linux.Arm64, publish for linux-arm64, use linux-arm64 in the path of the Dockerfile, build with --platform linux/arm64 and create the function with the arm64 architecture.

  • At least 2048 MB of memory; Lambda gives processor power in proportion to it
  • A timeout of 2 minutes or more: the first request of a new environment takes 7 to 10 seconds, then a page converts in a fraction of a second to a few seconds
  • A response holds 6 MB, about 4.5 MB of PDF in base64; larger documents go to S3

Step-by-step guide, with the function code →

Amazon ECS on Fargate

HTML to PDF in Amazon ECS

A Fargate task runs the Linux image of your application with the rendering runtime and the four system packages inside, so every task converts from its first request. Push the image to Elastic Container Registry, register the task definition and run it, or put an ECS service with a load balancer in front of the tasks. The same image runs in EKS, where one m5.xlarge node converted 10 two-page documents per second in our test, and in the Docker platform of Elastic Beanstalk.

task.json (excerpt)JSON
{
  "family": "pdf-app",
  "requiresCompatibilities": ["FARGATE"],
  "networkMode": "awsvpc",
  "cpu": "2048",
  "memory": "4096",
  "containerDefinitions": [{
    "name": "pdf-app",
    "image": "123456789012.dkr.ecr.eu-central-1.amazonaws.com/pdf-app:1",
    "portMappings": [{ "containerPort": 8080 }]
  }]
}
Dockerfile, registry, roles and the run command in the ECS guide →

Sizing and results

  • 2 vCPUs and 4 GB of memory per task
  • Measured in Frankfurt: a simple page in about 170 ms, close to 4 conversions per second with four in parallel
  • An ECS service with an Application Load Balancer for production traffic
FAQ

HTML to PDF in AWS: common questions

Which instance type does the converter need?

We recommend t3.medium (2 vCPUs, 4 GB) as the smallest type for development and testing, in place of the t3.micro the console selects. Windows Server uses about 2 GB of memory itself, so production environments on Windows start at t3.large; on Linux pick more memory as the documents grow in size and complexity.

Do I need to install anything on the instances?

On Windows Server, nothing. On Amazon Linux 2023 the HTML to PDF component needs four system packages (NSS, AT-SPI2/ATK bridge, Cairo, Pango) and the DejaVu fonts, installed by the .ebextensions configuration file that travels with the application, without any manual step on the instance.

Does it work in a load-balanced environment with autoscaling?

Every instance Elastic Beanstalk adds applies the configuration file before it receives requests, so a new instance converts like the first one. A load-balanced application runs on several instances and is licensed with a Company License.

Can I run the converter in AWS Lambda?

Yes, as a function packaged as a container image built from the Lambda base image for .NET 10 or .NET 8, with the four system packages and the DejaVu fonts installed in the image. Give the function at least 2048 MB and a timeout of 2 minutes. In our tests, on x86_64 and on arm64, the first request of a new execution environment took 7 to 10 seconds; after it a one-page document converted in 0.2 to 0.3 seconds and a six-page web page in 2 to 3.5 seconds. A zip deployment does not fit the runtime.

Can I use Graviton instances?

Choose the arm64 architecture when you create the environment and reference EvoPdf.Next.Linux.Arm64. The configuration file is the same, with linux-arm64 in place of linux-x64 in the two paths. Lambda functions run on Graviton as well: build the image with --platform linux/arm64 and create the function with the arm64 architecture.

Does it run in Amazon ECS?

On Fargate, from the Linux image of the application with the four packages installed in it. We recommend 2 vCPUs and 4 GB per task; with this size a simple page converted in about 170 ms in our tests. The same image runs in EKS with the Kubernetes guide: one m5.xlarge node converted 10 two-page documents per second in our test.

How is it licensed in AWS?

A single instance is covered by a Deployment License. An application running on several instances (load balancing, autoscaling, containers) needs a Company License. Pricing & licensing.

Download the demo application

The ASP.NET Core demo with complete C# source, ready to publish to Elastic Beanstalk on Linux or Windows or to build as the image of an ECS task; the library comes from NuGet. The Lambda function is in the documentation guide.