Luismr
Luismr

Reputation: 13

HTML to PDF Using CefSharp

I´m looking for the best way to convert HTML to PDF using CefSharp, I think this library is a good option because I can directly use the Chromium Html Render but I don't know how to start.

Upvotes: 0

Views: 1743

Answers (1)

user1448816
user1448816

Reputation:

You can leverage the builtin method to save whole html page as pdf use the code mentioned below for your reference, Please check if it helps.

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

You can use open file dialog box to take file name from user

Upvotes: 2

Related Questions