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 (DynamicPDFHTMLConverterForNETv2.XX.zip) contains the following files.
- DynamicPDF.HTMLConverter.dll
- DynamicPDF.HTMLConverter.xml
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-gpu
arguments. 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.
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 chromium RUN 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.