hugobelman.wkhtmltopdf 1.0.0

dotnet add package hugobelman.wkhtmltopdf --version 1.0.0
NuGet\Install-Package hugobelman.wkhtmltopdf -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="hugobelman.wkhtmltopdf" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add hugobelman.wkhtmltopdf --version 1.0.0
#r "nuget: hugobelman.wkhtmltopdf, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install hugobelman.wkhtmltopdf as a Cake Addin
#addin nuget:?package=hugobelman.wkhtmltopdf&version=1.0.0

// Install hugobelman.wkhtmltopdf as a Cake Tool
#tool nuget:?package=hugobelman.wkhtmltopdf&version=1.0.0

WkHtmlToPDF C# Wrapper (.NET Framework)

A small and easy-to-use wrapper for convert Html files to Pdf files with wkhtmltopdf executable for C# .NET Framework.

Install

  1. Install Nuget Package
Install-Package hugobelman.wkhtmltopdf
  1. Download wkhtmltopdf from here flavor MXE (MinGW-w64) win32/win64
  2. Decompress and move wkhtmltox/bin/wkhtmltopdf.exe where your executable is or specify their location in the WkHtmlToPdf object constructor.

Usage

var wkHtmlToPdf = new hugobelman.wkhtmltopdf.WkHtmlToPdf();
wkHtmlToPdf.ConvertHTMLToPDF("input.html", "output.pdf");

Or

var wkHtmlToPdf = new hugobelman.wkhtmltopdf.WkHtmlToPdf();
var pdfOptions = new hugobelman.wkhtmltopdf.WkHtmlToPdfOptions();

pdfOptions.Footer.Center = "Test";
pdfOptions.Header.Right = "[page] out of [topage]";
pdfOptions.PageSize = hugobelman.wkhtmltopdf.PaperSize.A4;
pdfOptions.Margin = new hugobelman.wkhtmltopdf.WkHtmlToPdfMargin(5.0f,10.0f,5.0f,5.0f);
pdfOptions.Dpi = 30

wkHtmlToPdf.ConvertHTMLToPDF("google.com", "output.pdf", pdfOptions);

Options

  • Dpi
  • Copies
  • ImageDpi
  • ImageQuality
  • Footer
  • Header
  • Margin
  • Encoding
  • PageOrientation
  • PageSize
  • NoCollate (Boolean)
  • GrayScale (Boolean)
  • LowQuality (Boolean)
  • NoBackground (Boolean)
  • EnableForms (Boolean)
  • NoImages (Boolean)
  • DisableLinks (Boolean)
  • DisableJavascript (Boolean)

In header and footer text string supplied the following variables will be substituted.

  • [page] Replaced by the number of the pages currently being printed
  • [frompage] Replaced by the number of the first page to be printed
  • [topage] Replaced by the number of the last page to be printed
  • [webpage] Replaced by the URL of the page being printed
  • [section] Replaced by the name of the current section
  • [subsection] Replaced by the name of the current subsection
  • [date] Replaced by the current date in system local format
  • [isodate] Replaced by the current date in ISO 8601 extended format
  • [time] Replaced by the current time in system local format
  • [title] Replaced by the title of the of the current page object
  • [doctitle] Replaced by the title of the output document
  • [sitepage] Replaced by the number of the page in the current site being converted
  • [sitepages] Replaced by the number of pages in the current site being converted

Testing

Tested with wkhtmltopdf.exe MXE (MinGW-w64) win32 / win64 Stable v 0.12.5

Licence

This library is under MIT Licence.

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 7,879 9/18/2019