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
Copy file name to clipboardExpand all lines: src/content/docs/browser-rendering/rest-api/pdf-endpoint.mdx
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,62 @@ curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-
142
142
--output "cloudflare.pdf"
143
143
```
144
144
145
+
### Customize page headers and footers
146
+
147
+
You can customize page headers and footers with HTML templates using the `headerTemplate` and `footerTemplate` options. Enable `displayHeaderFooter` to include them in your output. This example generates an A5 PDF with a branded header, a footer message, and page numbering.
148
+
149
+
```bash
150
+
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/pdf' \
"footerTemplate": "<div style=\"color: lightgray; border-top: solid lightgray 1px; font-size: 10px; padding-top: 5px; text-align: center; width: 100%;\"><span>This is a test message</span> - <span class=\"pageNumber\"></span></div>",
160
+
"margin": {
161
+
"top": "70px",
162
+
"bottom": "70px"
163
+
}
164
+
}
165
+
}' \
166
+
--output "header-footer.pdf"
167
+
```
168
+
169
+
### Include dynamic placeholders from page metadata
170
+
171
+
You can include dynamic placeholders such as `title`, `date`, `pageNumber`, and `totalPages` in the header or footer to display metadata on each page. This example produces an A4 PDF with a company-branded header, current date and title, and page numbering in the footer.
172
+
173
+
```bash
174
+
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/pdf' \
0 commit comments