Skip to content

Commit

Permalink
PdfOptions example (#1345)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Dec 6, 2019
1 parent 0835846 commit fded7a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions docfx_project/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<div id=\"footer-template\" style=\"font-size:10px !important; color:#808080; padding-left:10px\">Footer Text</div>"
});
```

## Inject HTML

```cs
Expand Down
2 changes: 1 addition & 1 deletion docfx_project/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit fded7a4

Please sign in to comment.