From fded7a435b2b03af1cfcb0391432807d1cfc852e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Fri, 6 Dec 2019 08:32:59 -0300 Subject: [PATCH] PdfOptions example (#1345) --- docfx_project/api/index.md | 25 +++++++++++++++++++++++++ docfx_project/index.md | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docfx_project/api/index.md b/docfx_project/api/index.md index 8e72f64b8..a3eb7371d 100644 --- a/docfx_project/api/index.md +++ b/docfx_project/api/index.md @@ -42,6 +42,31 @@ await page.GoToAsync("http://www.google.com"); await page.PdfAsync(outputFile); ``` +### Generate PDF files with custom options + +```cs +await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); +var browser = await Puppeteer.LaunchAsync(new LaunchOptions +{ + Headless = true +}); +var page = await browser.NewPageAsync(); +await page.GoToAsync("http://www.google.com"); +await page.PdfAsync(outputFile, new PdfOptions +{ + Format = PaperFormat.A4, + DisplayHeaderFooter = true, + MarginOptions = new MarginOptions + { + Top = "20px", + Right = "20px", + Bottom = "40px", + Left = "20px" + }, + FooterTemplate = "
Footer Text
" +}); +``` + ## Inject HTML ```cs diff --git a/docfx_project/index.md b/docfx_project/index.md index c7ef777ae..29a85d5eb 100644 --- a/docfx_project/index.md +++ b/docfx_project/index.md @@ -21,6 +21,6 @@ Puppeteer Sharp is a .NET port of the official [Node.JS Puppeteer API](https://g # Useful links -* Slack channel [#puppeteer-sharp](https://join.slack.com/t/puppeteer/shared_invite/enQtMzU4MjIyMDA5NTM4LTM1OTdkNDhlM2Y4ZGUzZDdjYjM5ZWZlZGFiZjc4MTkyYTVlYzIzYjU5NDIyNzgyMmFiNDFjN2UzNWU0N2ZhZDc) +* Slack channel [#puppeteer-sharp](https://puppeteer.slack.com/join/shared_invite/enQtMzU4MjIyMDA5NTM4LWI0YTE0MjM0NWQzYmE2MTRmNjM1ZTBkN2MxNmJmNTIwNTJjMmFhOWFjMGExMDViYjk2YjU2ZmYzMmE1NmExYzc) * [StackOverflow](https://stackoverflow.com/search?q=puppeteer-sharp) * [Issues](https://github.com/kblok/puppeteer-sharp/issues?utf8=%E2%9C%93&q=is%3Aissue) \ No newline at end of file