WeasyPrint Wrapper for .Net on Windows to generate pdf from html. It uses WeasyPrint to generate pdf from html without any extra installtion and setup on Windows.
Balbarak.WeasyPrint
simplifies the using of WeasyPrint on Windows
From nuget packages
PM> Install-Package Balbarak.WeasyPrint
using Balbarak.WeasyPrint
using System.IO;
using (WeasyPrintClient client = new WeasyPrintClient())
{
var html = "<!DOCTYPE html><html><body><h1>Hello World</h1></body></html>";
var binaryPdf = await client.GeneratePdfAsync(html);
File.WriteAllBytes("result.pdf",binaryPdf);
}
using (WeasyPrintClient client = new WeasyPrintClient())
{
var input = @"path\to\input.html";
var output = @"path\to\output.pdf";
await client.GeneratePdfAsync(input,output);
}
using (WeasyPrintClient client = new WeasyPrintClient())
{
var input = @"path\to\input.html";
var output = @"path\to\output.pdf";
client.OnDataError += OnDataError;
client.OnDataOutput += OnDataOutput;
await client.GeneratePdfAsync(input,output);
}
private void OnDataOutput(OutputEventArgs e)
{
Console.WriteLine(args.Data);
}
private void OnDataError(OutputEventArgs e)
{
Console.WriteLine(e.Data);
}
- WeasyPrint - BSD 3-Clause License
- Python 3.6 Embedded - License
- Gtk3 for Windows