Layout
Preconfigured Page Sizes
By default, a PDF's page size is set to A4. Using the API's page_size parameter a custom page size can be specified. Please find in the table below all page sizes supported by the PDFlayer API.
Example API Request:
Supported Page Sizes:
| Type | Sizes |
|---|---|
| A | A0, A1, A2, A3, A4, A5, A6, A7, A8, A9 |
| B | B0, B1, B2, B3, B4, B5, B6, B7, B8, B9 |
| Other | C5E, Comm10E, DLE, Executive, Folio, Ledger, Legal, Letter, Tabloid |
Dimensions
Instead of specifying a preconfigured Page Size the PDFlayer API also accepts two page dimension parameters. page_width and page_height.
Please be aware that specifying these dimension parameters will override any specified preconfigured Page Sizes.
Example API Request:
Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
page_width | numeric | - |
page_height | numeric | - |
Orientation
By default, a PDF's orientation is set to portrait. Using the API's orientation parameter the PDF document's orientation can be set to either portrait or landscape.
Example API Request:
Parameter Specification:
| Parameter | Supported Orientation Modes | Default |
|---|---|---|
| orientation | portrait, landscape | portrait |
Margins
A PDF's default margin is set to 10 millimeters on each side. Using the parameters margin_top, margin_bottom, margin_left and margin_right vertical and horizontal margins (in the selected Document Unit) can be specified.
Example API Request:
Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
margin_top | numeric | 10mm |
margin_bottom | numeric | 10mm |
margin_left | numeric | 10mm |
margin_right | numeric | 10mm |
Header
There are two different types of custom header elements that can be included in a PDF document: A header text or a custom header HTTP URL or raw HTML element.
Header Text
A simple header text can be specified by appending the PDFlayer API's header_text parameter to your API request URL and setting it to your preferred header text. By default, this header text is aligned at the center of the document. The API's header_align parameter enables you to specify a custom header alignment, choosing from left, right or center.
Example API Request:
Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
header_text | - | - |
header_align | center, left or right | center |
Header URL or Raw HTML Element
As an alternative to specifying a header text, the PDFlayer API is also capable of including the HTML contents of an external HTTP URL or raw HTML code as a header element in your final PDF document.
Example API Request using a HTTP header URL:
Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
header_url | HTTP GET & or HTTP POST | - |
header_html | HTTP POST only | - |
Header Spacing
By default, there is no extra space between a header element and the PDF document content. A header spacing can be specified by appending your preferred numeric value to the API's header_spacing parameter.
Example API Request using a HTTP header URL:
Footer
Just like with the PDF Header, there are two different types of custom footer elements that can be included in a PDF document: A footer text, a custom footer HTTP URL, or a raw HTML element.
Footer Text
A simple footer text can be specified by appending the PDFlayer API's footer_text parameter to your API request URL and setting it to your preferred footer text. By default, this footer text is aligned at the center of the document. The API's footer_align parameter enables you to specify a custom footer alignment, choosing from left, right or center.
Example API Request:
https://api.pdflayer.com/api/convert
? access_key = YOUR_ACCESS_KEY
& document_url = http://example.com/document.html
& footer_text = myFooterText
& footer_align = left
[...]
Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
footer_text | - | - |
footer_align | center, left or right | center |
Footer URL or Raw HTML Element
As an alternative to specifying a footer text, the PDFlayer API is also capable of including the HTML contents of an external HTTP URL or raw HTML code as a footer element in your final PDF document.
Example API Request using an HTTP footer URL:
Parameter specification:
| Parameter | Condition | Default |
|---|---|---|
footer_url | HTTP GET & or HTTP POST | - |
footer_html | HTTP POST only | - |
NOTE: Kindly ensure that the footer URL is formatted using the appropriate HTML tags. Please refer to the HTML snippet below for reference.
HTML Snippet:
Footer Spacing
By default, there is no extra space between a footer element and the PDF document content. A footer spacing can be specified by appending your preferred numeric value to the API's footer_spacing parameter.
Example API Request using an HTTP footer URL:
Viewport Control
The PDFlayer API's default viewport setting is 1440x900. You can specify a custom viewport size by setting the viewport parameter to your desired dimensions. (format: width x height, in pixels)
Important: When requesting mobile-sized viewports, it is highly recommended to also specify a user_agent parameter, as certain websites tend to ignore mobile viewports that come without specified HTTP User-Agent headers (See User-Agent parameter).
Example API request using permission options:
Parameter Specification
| Device | Viewport |
|---|---|
| iPhone 4 (s) | 320x480 |
| iPhone 5 (c/s) | 320x568 |
| iPhone 6 | 375x667 |
| iPhone 6 Plus | 414x736 |
| iPad (2/Mini/Retina) | 1024x768 |
| Samsung Galaxy S3, S4, S5 | 360x640 |
| Macbook 13" | 1440x900 |
| iMac 27" | 2560x1440 |