Skip to content

Codeuctivity/PuppeteerSharp.Renderer

Repository files navigation

Codeuctivity.HtmlRenderer

Nuget Build Donate

Renders HTML to PDF or PNGs

Render HTML to PDF

await using var chromiumRenderer = await Renderer.CreateAsync();
await chromiumRenderer.ConvertHtmlToPdf(sourceHtmlFilePath, desitinationPdf);

Render HTML to PNG

await using var chromiumRenderer = await Renderer.CreateAsync();
await chromiumRenderer.ConvertHtmlToPng(actualFilePath, pathRasterizedHtml);

Development

Linux / WSL

sudo apt install libgbm-dev libatk-bridge2.0-0 libnss3 libcups2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libpango-1.0-0 libcairo2 libasound2

... and if that fails you can either find out which dependency is missing on your system or you take a shortcut

sudo apt install -y chromium-browser