Referencing the Assemblies
You can install the DynamicPDF HTML Converter NuGet package directly within Visual Studio using the Visual Studio Package Manger.
- NuGet: ceTe.DynamicPDF.HtmlConverter.NET (https://www.nuget.org/packages/ceTe.DynamicPDF.HtmlConverter.NET)
NOTE: We recommend installing using the NuGet package, as this is the easiest and least error-prone installation method.
To install manually, download the assembly from the DynamicPDF website. The downloaded zip file (DynamicPDFHTMLConverterForNETv1.XX.zip) contains the following files.
However, the easiest way to install is using NuGet.
You can also deploy DynamicPDF HTML Converter on the Linux operating system. The following instructions outline the steps required.
NOTE: The following instructions require DynamicPDF HTML Converter v1.05 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 --headless --no-sandbox --no-gpu
- 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 --no-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.
You can deploy DynamicPDF HTML Converter within a Docker container and deploy it to an Azure App Service or any other similar environment. Here are the steps to create a Docker container. and deploying to 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 this link https://code.visualstudio.com/docs/containers/app-service to Deploy to Azure App Service using VS Code.