Document Name
By default, PDF documents generated by the PDFLayer API are named pdflayer.pdf. Using the API's document_name parameter you can specify a custom name for your final PDF document. The name is used exactly as sent: .pdf is not added, so include it in the name (for example MyPDF.pdf).
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&document_name=MyPDF.pdfParameter Specification:
| Parameter | Condition | Default |
|---|---|---|
| document_name | Max. 180 characters | pdflayer.pdf |
Document Units
The default document unit is px. A custom unit can be specified by appending the API's custom_unit parameter and setting it to one of the five supported document units (values are case-sensitive). The unit parameter is an alias of custom_unit; if both are sent, unit wins.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&custom_unit=mmParameter Specification:
| Parameter | Supported Units | Default |
|---|---|---|
| custom_unit | mm, cm, in, px, pt | px |
HTTP User-Agent Header
The API's user_agent parameter is used to adjust the final PDF document to a certain device setting. In many cases, this parameter is used to ensure more consistent functionality of the Viewport Control feature.
To specify a custom HTTP User-Agent header, simply append the respective User-Agent string to the user_agent parameter.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&user_agent=Mozilla/5.0%20(Windows%20NT%206.1;%20WOW64)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/42.0.2311.135%20Safari/537.36Common HTTP User-Agent Headers:
| System | UA String |
|---|---|
| Chrome Generic Win7 64-bit | Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 |
| Chrome Generic MacOSX | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 |
| Safari 8.0 MacOSX | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.6.3 (KHTML, like Gecko) Version/8.0.6 Safari/600.6.3 |
| Firefox Generic Win7 64-bit | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0 |
Find a detailed list of HTTP User-Agent headers here »
HTTP Accept-Language Header
By default, PDF documents processed by the PDFLayer API don't come with a specific HTTP Accept-Language header. An Accept-Language header can be specified by appending the respective string to the API's accept_lang parameter.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&accept_lang=en-USCommon HTTP Accept-Language Headers:
| Language | Accept-Language String |
|---|---|
| English (general) | en |
| German | de |
| Spanish | es |
| Italian | it |
| English (US) | en-US |
| English (UK) | en-GB |
| Spanish (Spain) | es-ES |
| Spanish (Mexico) | es-MX |
You can find a comprehensive list of accept-language strings here.
TTL (Caching Time)
By default, generated PDFs are cached for a period of 30 days (2,592,000 seconds). Using the API's ttl parameter, you can specify a custom caching time (in seconds) lower than the default setting.
The example API query below requests the final PDF to be cached for 259,200 seconds (3 days).
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&ttl=259200Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
| ttl | Maximum value: 2592000 | 2592000 |
Force New PDF
As mentioned earlier, by default PDF documents are cached for 30 days upon creation. (Learn more about TTL - Caching Time)
By setting the PDFLayer API's force parameter to 1 the API will be requested to generate a new PDF each time the API request URL is called.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&force=1Please Note: Each call of an API request URL including the
forcefunctionality counts towards your monthly API request volume.
Inline/Attachment Parameter
By default, accessing a PDFLayer API request URL in a browser will trigger the download of the generated PDF (attachment behaviour). By setting the API's inline parameter to 1 the API will be requested to display the PDF in the browser instead (inline behaviour).
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&inline=1Parameter Specification:
| Parameter | Condition | Default |
|---|---|---|
| inline | - | Deactivated - Attachment, triggering download |
Password-Protected Sites
The PDFLayer API can also generate PDFs from password-protected websites. The parameters auth_user and auth_pass are used to authenticate with a password-protected website.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&auth_user=myUsername&auth_pass=myPasswordParameter Specification:
| Parameter | Condition | Default |
|---|---|---|
| auth_user | Maximum: 1,000 characters | - |
| auth_pass | Maximum: 1,000 characters | - |
PDF Encryption
There are three encryption levels available for PDFs generated by the PDFLayer API: 40-bit, 128-bit and 256-bit. In order to activate encryption, set the API's encryption parameter to 40, 128 or 256.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&encryption=128Parameter Specification:
| Parameter | Supported Encryption Levels | Default |
|---|---|---|
| encryption | 40, 128, 256 | - |
PDF Authentication
The PDFLayer API offers two levels of PDF password protection: owner password and user password. These can be specified by appending the owner_password and user_password parameter(s) and setting them to their respective password value. You can set either password on its own, or both.
Supplying an owner password grants unlimited access to the PDF, including the ability to change the password and Permission Options. A user password, on the other hand, must be supplied to view the document and perform operations allowed by the Permission Options.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&owner_password=myOwnerPassword&user_password=myUserPasswordParameter Specification:
| Parameter | Supported Encryption Levels | Default |
|---|---|---|
| owner_password | Maximum: 32 characters | - |
| user_password | Maximum: 32 characters | - |
Misc Options
In addition to the above-mentioned document configuration parameters, there is a series of extra settings that can be specified for the final PDF document. Please find them in the table below:
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&no_hyperlinks=1&grayscale=1Parameter Specification:
| Parameter | Description | Default |
|---|---|---|
| no_images | Set to 1 in order to disable images | - |
| no_hyperlinks | Set to 1 in order to make links unclickable | - |
| no_backgrounds | Set to 1 in order to disable CSS backgrounds | - |
| no_javascript | Set to 1 in order to run no JavaScript at all | - |
| use_print_media | Set to 1 in order to activate CSS @media print declarations | - |
| grayscale | Set to 1 in order to remove all colours | - |
| low_quality | Set to 1 in order to generate low quality PDF | - |
Note: only 1 switches these settings on; 0 or any other value means off.
Permission Options
PDFLayer allows you to configure document permission options such as printing, copying, and modification restrictions at the time of PDF generation. Certain permission flags, including no_print, no_copy, and no_modify, can now be applied without requiring an owner_password, user_password, or the encryption parameter. These restrictions are embedded directly during PDF creation.
For advanced security features — such as password-protected documents, encrypted PDFs, or permissions that require post-generation control — Please check the PDF Authentication section.
After a PDF is generated, permission settings that rely on passwords or encryption can only be changed or removed by supplying the owner password."
Example API request using permission options:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=http://example.com/document.html&encryption=128&no_print=1&no_modify=1&no_copy=1Parameter Specification:
| Parameter | Description | Default |
|---|---|---|
| no_print | Set to 1 in order to disable printing of the final PDF document | - |
| no_modify | Set to 1 in order to disable modification of the final PDF document | - |
| no_copy | Set to 1 in order to disable the possibility to copy any text of the final PDF document | - |
Test Mode
Set test=1 to get a PDF with a "TEST" watermark (70% opacity) on every page. It replaces any watermark_url, and test requests are not counted against your quota.
Example API Request:
https://api.apilayer.net/pdflayer/api/convert?access_key=YOUR_ACCESS_KEY&document_url=https://example.com&test=1