Referencing the Assemblies
You can install DynamicPDF HTML Converter through Nuget or manually.
NuGet Installation
To install the NuGet Package, simply navigate to Visual Studio's Package Manager and install it from there. The DynamicPDF HTML Converter relies on the NuGet package "ceTe.DynamicPDF.HtmlToPDFResources" as a dependency, which contains the essential Chromium files necessary for the conversion process.
However, please note that you also have the flexibility to utilize locally installed Edge, Chromium, or similar resources instead of relying solely on the ones provided by us.
- NuGet: ceTe.DynamicPDF.HtmlConverter.NET (https://www.nuget.org/packages/ceTe.DynamicPDF.HtmlConverter.NET)
- NuGet: ceTe.DynamicPDF.HtmlToPDFResources.NET (https://www.nuget.org/packages/ceTe.DynamicPDF.HtmlToPDFResources.NET)
We recommend installing using the NuGet package, as this is the easiest and least error-prone installation method.
Manual Installation
To install manually, download the assembly from the DynamicPDF website. The downloaded zip file (DynamicPDFHTMLConverterForNETv3.XX.zip) contains the following files.
- DynamicPDF.HTMLConverter.dll
- DynamicPDF.HTMLConverter.xml
- DynamicPDF.Converter.Service.exe
- DynamicPDF.Converter.Service.exe.config
Service Installation
In environments where your application runs under a user account with limited access to system resources (such as an IIS-hosted application), DynamicPDF HTMLConverter for .NET requires a Windows service to perform HTML to PDF conversions. The DynamicPDF.HTMLConverter.dll assembly will automatically detect and utilize this service when available.
If you are using the DynamicPDF Converter for .NET product, please follow the installation and usage instructions provided with that product, as both versions use the same Windows service.
Installing the DynamicPDF Converter Service
- Uninstall any previous versions of the DynamicPDF Converter service before installing this version.
- The "DPDFConverterService" folder contains the following files:
- DynamicPDF.Converter.Service.exe
- DynamicPDF.Converter.Service.exe.config
- ReadMe.txt
- Copy or move these files to a permanent location on your system.
- Open Command Prompt as Administrator (Right-click > Run as administrator).
- Navigate to the folder containing the above files, and run the following command to install the service:
- DynamicPDF.Converter.Service.exe /r
- A pop-up dialog will appear prompting you to enter the credentials of the user account under which the service will run.
Uninstalling the DynamicPDF Converter Service
- Open Command Prompt as Administrator.
- Navigate to the folder where the service is installed, and run the following command to uninstall it:
- DynamicPDF.Converter.Service.exe /u
Linux Deployment
You can also deploy DynamicPDF HTML Converter on the Linux operating system. The following instructions outline the steps required.
The following instructions require DynamicPDF HTML Converter v2.0 or higher.
- Install Chrome or a Chromium based browser on the Linux system you wish to install DynamicPDF HTML Converter. These instructions will vary depending on your computer's Linux distribution.
- Test the installation by ensuring the following command runs without errors in headless mode.
chromium --no-sandbox --disable-gpu --headless
- Set the Converter.ChromiumProcessPath static property to the path to your Chromium installation before doing the first conversion.
- Set the Converter.TemporaryDirectory to a directory that has read/write access to the application using the DynamicHTML Converter.
- By default, start the Chromium process using the
--no-sandbox --disable-gpuarguments. On some systems you may also need to add additional arguments. In this situation, set the Converter.ChromiumProcessArgs property to the required additional arguments before performing the conversion.
Linux deployment requires Chrome or a Chromium based browser.
Container Deployment
You can deploy DynamicPDF HTML Converter within a Docker container and deploy it to an Azure App Service or any other similar environment. The following steps create a Docker container and deploy it to an Azure App Service.
Debian or Ubuntu based images can be used, however Alpine is not supported. The Alpine container image is not supported as it uses musl library instead of libc.
-
Add Docker support to the ASP.NET project that is using DynamicPDF HTML Converter.
-
This sample uses Debian. Ubuntu can also be used, however the commands may vary.
-
Add these lines of code in the docker file to install chromium under the base image.
# Install chromiumRUN apt-get update && apt-get install chromium -y# Install required fonts. [Optional step]# RUN apt update && apt install fonts-indic -y# && fc-cache -f -
Set the TemporaryDirectory and ChromiumProcessPath properties in code when the application starts. If the temporary directory is not preset, it will be created as long as the process has the required permissions.
Converter.ChromiumProcessPath = "/usr/bin/chromium";Converter.TemporaryDirectory = "/dpdfTemp"; -
Running the application creates the Docker image.
-
Push the Docker image to the Azure Container registry or Docker Hub and create an App Service using the image.
Refer to https://code.visualstudio.com/docs/containers/app-service to Deploy to Azure App Service using VS Code.