Skip to content

Commit fded7a4

Browse files
authored
PdfOptions example (#1345)
1 parent 0835846 commit fded7a4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

docfx_project/api/index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,31 @@ await page.GoToAsync("http://www.google.com");
4242
await page.PdfAsync(outputFile);
4343
```
4444

45+
### Generate PDF files with custom options
46+
47+
```cs
48+
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
49+
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
50+
{
51+
Headless = true
52+
});
53+
var page = await browser.NewPageAsync();
54+
await page.GoToAsync("http://www.google.com");
55+
await page.PdfAsync(outputFile, new PdfOptions
56+
{
57+
Format = PaperFormat.A4,
58+
DisplayHeaderFooter = true,
59+
MarginOptions = new MarginOptions
60+
{
61+
Top = "20px",
62+
Right = "20px",
63+
Bottom = "40px",
64+
Left = "20px"
65+
},
66+
FooterTemplate = "<div id=\"footer-template\" style=\"font-size:10px !important; color:#808080; padding-left:10px\">Footer Text</div>"
67+
});
68+
```
69+
4570
## Inject HTML
4671

4772
```cs

docfx_project/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ Puppeteer Sharp is a .NET port of the official [Node.JS Puppeteer API](https://g
2121

2222
# Useful links
2323

24-
* Slack channel [#puppeteer-sharp](https://join.slack.com/t/puppeteer/shared_invite/enQtMzU4MjIyMDA5NTM4LTM1OTdkNDhlM2Y4ZGUzZDdjYjM5ZWZlZGFiZjc4MTkyYTVlYzIzYjU5NDIyNzgyMmFiNDFjN2UzNWU0N2ZhZDc)
24+
* Slack channel [#puppeteer-sharp](https://puppeteer.slack.com/join/shared_invite/enQtMzU4MjIyMDA5NTM4LWI0YTE0MjM0NWQzYmE2MTRmNjM1ZTBkN2MxNmJmNTIwNTJjMmFhOWFjMGExMDViYjk2YjU2ZmYzMmE1NmExYzc)
2525
* [StackOverflow](https://stackoverflow.com/search?q=puppeteer-sharp)
2626
* [Issues](https://github.com/kblok/puppeteer-sharp/issues?utf8=%E2%9C%93&q=is%3Aissue)

0 commit comments

Comments
 (0)