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 -Version 0.7.1
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 = client.GeneratePdf(html);
File.WriteAllBytes("result.pdf",binaryPdf);
}
using (WeasyPrintClient client = new WeasyPrintClient())
{
var input = @"path\to\input.html";
var output = @"path\to\output.pdf";
client.GeneratePdf(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;
client.GeneratePdf(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