TuesPechkin is a .NET Wrapper for the wkhtmltopdf library.
TuesPechkin is a .NET Wrapper for the wkhtmltopdf library.
Supported usage
- It supports .NET 2.0+, 32 and 64-bit processes, and IIS-hosted applications.
- Azure Websites does not currently support the use of wkhtmltopdf.
- It is not tested with any operating systems besides Windows.
- It is available as a NuGet package for your convenience.
- It is built and tested around wkhtmltopdf 0.12.2.
- Even if you use the IIS-compatible method documented below, you may only use one converter/toolset instance per application pool/process. A workaround is being researched for a future version.
Example
1. Create a document with options of your choosing.
var document = new HtmlToPdfDocument
{
GlobalSettings =
{
ProduceOutline = true,
DocumentTitle = "Pretty Websites",
PaperSize = PaperKind.A4, // Implicit conversion to PechkinPaperSize
Margins =
{
All = 1.375,
Unit = Unit.Centimeters
}
},
Objects = {
new ObjectSettings { HtmlText = "<h1>Pretty Websites</h1><p>This might take a bit to convert!</p>" },
new ObjectSettings { PageUrl = "www.google.com" },
new ObjectSettings { PageUrl = "www.microsoft.com" },
new ObjectSettings { PageUrl = "www.github.com" }
}
};
2. Create a converter for an IIS-hosted application
IConverter converter =
new ThreadSafeConverter(
new RemotingToolset<PdfToolset>(
new Win32EmbeddedDeployment(
new TempFolderDeployment())));
// Keep the converter somewhere static, or as a singleton instance!
// Do NOT run the above code more than once in the application lifecycle!
byte[] result = converter.Convert(document);