Documentation
DGtalSharp.PDF
DGtalSharp.Pdf is a cross platform .Net component which creates pdf from html. Its based-on Chromium engine and supports latest html/css syntax.
Offline Support
There are multiple options available to make it work offline without internet connection.
Install Native Packages
DGtalSharp.Pdf has native Operating System packages to work offline without downloading any native dependency. Install any (or all) of these packages depending on target OS.
For Windows 64
Install-Package DGtalSharp.Pdf.Win64
For Windows 86
Install-Package DGtalSharp.Pdf.Win32
For Linux or Docker
Install-Package DGtalSharp.Pdf.Linux
For MAC
Install-Package DGtalSharp.Pdf.Mac
Use Local Browser
DGtalSharp Pdf can work with local browsers, already installed on target OS. If you have Google Chrome or Microsoft Edge already installed on machine, Set a flag to use local browser instance instead of downloading dependencies
To enable local browser preference, use following line before calling initialization
//Use local browser installed on target system
DGtalSharp.Pdf.PdfGlobalSettings.PreferLocalBrowser = true;
Preference can also be configured to use MS Edge instead of Chrome
//Use local browser installed on target system
DGtalSharp.Pdf.PdfGlobalSettings.PreferLocalBrowser = true;
DGtalSharp.Pdf.PdfGlobalSettings.PreferLocalChrome = false;
In summary, following code would use local browser instead of downloading dependent components
//Use local browser installed on target system
DGtalSharp.Pdf.PdfGlobalSettings.PreferLocalBrowser = true;
//Set global preference before initializing Pdf component
await DGtalSharp.Pdf.PdfInitializer.Initialize();
Target system must have Chrome or MS Edge browser installed
Docker Image
Self host docker image html2pdf and use REST endpoints to create Pdf
Pull image
docker pull hisabir/html2pdf
Run docker
docker run -p 80:80 hisabir/html2pdf
Now open url http://localhost/swagger/index.html in browser
Port can be changed using parameter '-p'. Following command will run docker on port 8888
docker run -p 8888:80 hisabir/html2pdf
Now open url http://localhost:8888/swagger/index.html in browser
OpenApi(Swagger) specs can be used to generate pdf from url/html. To create a pdf from url, simply send a request to
http://localhost:8888/api/Pdf/google.com/google
Note: change url port in above request.
For more details, please refer to Docker page