Statiq.Web icon indicating copy to clipboard operation
Statiq.Web copied to clipboard

Create a Pdf module

Open daveaglick opened this issue 9 years ago • 3 comments

Convert HTML content to PDF

daveaglick avatar Jun 16 '15 01:06 daveaglick

Hi @daveaglick , which HTML files you want to convert?

MetalDent avatar Oct 05 '19 12:10 MetalDent

The goal would be to convert HTML content stored in documents. The specific set of documents that get converted, how they’re aggregated into a single output PDF, and other details would need to be configurable.

As for use cases, I could see integrating this module into the docs pipelines to optionally produce a PDF of the documentation.

A word of caution - Wyam is no longer accepting PRs. If there’s interest in looking at this, head on over to Statiq Framework.

daveaglick avatar Oct 05 '19 15:10 daveaglick

Could consider something like CefSharp which embeds the Chromium engine: https://github.com/cefsharp/CefSharp

Generating a PDF would be essentially one or two lines of code: https://stackoverflow.com/a/61723341/6287173

var success = await webBrowserObject.PrintToPdfAsync("filename.pdf", new PdfPrintSettings
{
    MarginType = CefPdfPrintMarginType.Custom,
    MarginBottom = 10,
    MarginTop = 0,
    MarginLeft = 20,
    MarginRight = 10,
    PageWidth = 210000,
    PageHeight = 297000
});

daveaglick avatar Mar 10 '22 14:03 daveaglick