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:

TypeSizes
AA0, A1, A2, A3, A4, A5, A6, A7, A8, A9
BB0, B1, B2, B3, B4, B5, B6, B7, B8, B9
OtherC5E, 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:

ParameterConditionDefault
page_widthnumeric-
page_heightnumeric-

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:

ParameterSupported Orientation ModesDefault
orientationportrait, landscapeportrait

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:

ParameterConditionDefault
margin_topnumeric10mm
margin_bottomnumeric10mm
margin_leftnumeric10mm
margin_rightnumeric10mm

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:

ParameterConditionDefault
header_text--
header_aligncenter, left or rightcenter

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:

ParameterConditionDefault
header_urlHTTP GET & or HTTP POST-
header_htmlHTTP 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:

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.

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:

ParameterConditionDefault
footer_text--
footer_aligncenter, left or rightcenter

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:

ParameterConditionDefault
footer_urlHTTP GET & or HTTP POST-
footer_htmlHTTP 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:

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

DeviceViewport
iPhone 4 (s)320x480
iPhone 5 (c/s)320x568
iPhone 6375x667
iPhone 6 Plus414x736
iPad (2/Mini/Retina)1024x768
Samsung Galaxy S3, S4, S5360x640
Macbook 13"1440x900
iMac 27"2560x1440

 

Questions? Contact Sales .
Need help? Contact Support .
© 2025 APILayer. All rights reserved.