Quickstart Guide


The PDFlayer API is extremely easy to use. It only takes a few lines of code to make your first validation request. All registered users, whether on a free or paid plan, can use our Quickstart Guide to explore the full range of API functionalities with just one click.

  • Existing users: Access the Quickstart Guide below.
  • New users: Create an account and get started in minutes.

To ensure maximum compatibility with any existing programming language, the PDFlayer API uses simple HTTP requests with URLs. The following steps outline, in the most basic terms, how an API request is built.

Step 1: Get Your API Access Key

Sign up for a free PDFlayer account at pdflayer.com and obtain your personal API Access Key

This key authenticates your requests and ensures that you have access to the API features provided by your subscription plan.

Step 2: Base URL

Each API request is based on the following URL:

Step 3: Required Parameters

Simply authenticate with the API by appending your access_key and providing either a URL using the document_url parameter or raw HTML code using the document_html parameter.

ParameterDescription
access_keyKey used to authenticate with the API - find it in your Account Dashboard
document_urlThe full URL (including the HTTP Protocol) of the website you want to convert to a PDF document, e.g. http://example.com/invoice.html
document_htmlHTTP POST only - raw HTML code you would like to convert to a PDF document.

Step 4: Optional Parameters

In addition to the few required parameters, there is a set of functionalities and parameters that can be used to fully configure and customize your PDF document. 

Find below a summary:  Configuration

ParameterDescriptionDefault
document_namespecify a PDF name of up to 180 characters.pdflayer.pdf
custom_unitset to px (Pixels), pt (Points), in (Inches) or mm (Millimeters)px
user_agentset to your preferred User-Agent header stringSee below
accept_langset to your preferred Accept-Language header stringen-US
text_encodingset to your preferred text encoding stringutf-8
ttlthe time (in seconds) a generated PDF is cached2,592,000
forceset to 1 to force new PDF-
inlineset to 1 to display PDF document inlineAttachment, triggers download
auth_userspecify username used to access password-protected site-
auth_passspecify password used to access password-protected site-
encryptionset to 40 (40-bit) or 128 (128-bit)-
owner_passwordspecify owner password to password protect PDF-
user_passwordspecify user password to password protect PDF-
Misc Optionsa series of configuration options [Learn more]-
Permissionsa series of permission options [Learn more]-

Find below a summary:  Layout

ParameterDescriptionDefault
page_sizeset to preferred page size, e.g. A4, A5, etc.A4
page_widthspecify page width (numeric), e.g. 200 (overrides page_size)A4 width
page_heightspecify page height (numeric), e.g. 600 (overrides page_size)A4 height
orientationset to portrait or landscapeportrait
margin_topset to preferred top margin value (numeric), e.g. 5-
margin_bottomset to preferred bottom margin value (numeric), e.g. 5-
margin_leftset to preferred left margin value (numeric), e.g. 5-
margin_rightset to preferred right margin value (numeric), e.g. 5-
header_spacingset to preferred header spacing value (numeric), e.g. 10-
header_textset to preferred header text, e.g. This is my heading-
header_alignset to left, center or rightcenter
header_urlset to (urlencoded) URL containing your preferred header HTML elements-
header_htmlHTTP POST only - specify raw HTML as header element-
footer_spacingset to preferred footer spacing value (numeric), e.g. 10-
footer_textset to preferred footer text, e.g. This is my footer-
footer_alignset to left, center or rightcenter
footer_urlset to (urlencoded) URL containing your preferred footer HTML elements-
footer_htmlHTTP POST only - specify raw HTML as footer element-
viewportSet to preferred viewport "width x height", e.g. 320x4801440x900

Find below a summary:  Customization

ParameterDescriptionDefault
css_urlinject a custom CSS stylesheet using a (urlencoded) URL-
delayspecify a delay (in seconds) before PDF is captured-
dpispecify the DPI resolution (numerical) between 10 and 1000096
zoomspecify page zoom factor between 0 and 50-
watermark_urlspecify a watermark URL (urlencoded) containing a PNG or JPG image-
watermark_offset_xspecify a horizontal watermark offset, e.g. 10-
watermark_offset_yspecify a vertical watermark offset, e.g. 10-
watermark_opacityspecify watermark opacity percentage (numeric) between 0 and 10020
watermark_in_backgroundset to 1 to place watermark behind text-
Page NumberingPage numbering options including dynamic tags [Learn more]-

Find below a summary:  Document Details 

ParameterDescriptionDefault
titlespecify a PDF document title of max. 150 characters-
subjectspecify a PDF document subject of max. 150 characters-
creatorspecify a PDF document creator name of max. 150 characterspdflayer.com
authorspecify a PDF document author name of max. 150 characters-

Sample API request:

The following API request uses some of the above optional parameters to convert a standard HTML invoice to a PDF.

URL Encoding

Strictly speaking, it is always safer to URL-encode the URL before passing it into any API parameter. However, URL encoding is required in case your the respective URL contains the special character &.

Example URLs:

Find below an example url that is required to be URL encoded in order to be processed correctly.

Example query:

This is how the example URL above has to be passed into an API request:

Not sure about URL encoding? Have a look at this reference page »

 

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