You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have HTML you'd like to generate a PDF from, the `html` optioncan be used. The option `addStyleTag`can be used to add custom styles.
74
+
If you have raw HTML you'd like to generate a PDF from, use the `html` option. You can still apply custom styles using the `addStyleTag`parameter.
75
75
76
76
```bash
77
77
curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-rendering/pdf \
@@ -89,9 +89,13 @@ curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-
89
89
90
90
## Advanced usage
91
91
92
-
Navigate to `https://example.com`, first setting an additional HTTP request header and configuring the page size (`viewport`). Then, wait until there are no more than 2 network connections for at least 500 ms, or until the maximum timeout of 4500 ms is reached, before considering the page loaded and returning the rendered PDF document.
92
+
Many more options exist, such as setting HTTP credentials using `authenticate`, setting `cookies`, and customizing load behavior using `gotoOptions`. **Check the full endpoint [reference](/api/resources/browser_rendering/subresources/pdf/methods/create/) for all available parameters.**
93
93
94
-
The `goToOptions` parameter exposes most of [Puppeteer'd API](https://pptr.dev/api/puppeteer.gotooptions).
94
+
### Advanced Page Load with Custom Headers and Viewport
95
+
96
+
Navigate to `https://example.com`, setting additional HTTP headers and configuring the page size (viewport). The PDF generation will wait until there are no more than 2 network connections for at least 500 ms, or until the maximum timeout of 4500 ms is reached, before rendering.
97
+
98
+
The `goToOptions` parameter exposes most of [Puppeteer's API](https://pptr.dev/api/puppeteer.gotooptions).
95
99
96
100
```bash
97
101
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/pdf' \
@@ -114,9 +118,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
114
118
--output "advanced-output.pdf"
115
119
```
116
120
117
-
## Blocking images and styles when generating a PDF
121
+
## Blocking Images and Styles when Generating a PDF
118
122
119
-
The options `rejectResourceTypes` and `rejectRequestPattern` can be used to block requests. The opposite can also be done, _only_ allow certain requests using `allowResourceTypes` and `allowRequestPattern`.
123
+
The options `rejectResourceTypes` and `rejectRequestPattern` can be used to block requests during rendering. The opposite can also be done, _only_ allow certain requests using `allowResourceTypes` and `allowRequestPattern`.
120
124
121
125
```bash
122
126
curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-rendering/pdf \
@@ -129,5 +133,3 @@ curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-
129
133
}' \
130
134
--output "cloudflare.pdf"
131
135
```
132
-
133
-
Many more options exist, like setting HTTP credentials using `authenticate`, setting `cookies`, and using `gotoOptions` to control page load behaviour - check the endpoint [reference](/api/resources/browser_rendering/subresources/pdf/methods/create/) for all available parameters.
0 commit comments