Quick Start

Generate PDF from URL POST GET
                            curl --request GET --url https://pdfmatrix.com/api/v1/get \
    ? api_token = [your api token] \
    & url = https://google.com


                            
Generate PDF from HTML POST
                            curl --request POST --url https://pdfmatrix.com/api/v1/get \
    ? api_token = [your api token] \
    & html = '<strong>Hello</strong>'



                            

Laravel SDK

Installation instructions and usage examples on github:
https://github.com/gdinko/pdfmatrix-sdk



Authentication

With each API call, you must provide an authentication token. To get your token please refer to your user account dashboard.

Provide the token as an api_token querystring parameter.
                            
https://pdfmatrix.com/api/v1/get?api_token={TOKEN}
                            
                            

Response Options

Parameter Description Options Default
return By default, the API returns JSON response.

It is possible to receive the raw document using return: pdf parameter or return: download to receive pdf stream.

If you want the file to be saved for 30 days in the cloud use return: storage_link, the API will return JSON response with link for download, valid 30 days or until the file is deleted by the user.
json
pdf download storage_link
json
returnParams Returns request parameters in response. true false false
returnScreenshot Returns pdf and screenshot in png format with response.
*this will slow down the process
*only with return=json
true false false
Example JSON Response.
                            {
    "startTime":"2019-12-19 20:21:05",
    "status":200,
    "code":200,
    "error":"",
    "pdf":"base64 encoded pdf",
    "screenShot":"base64 encoded screenshot in png format",
    "plan_limit":100,
    "remaining_limit":70,
    "endTime":"2019-12-19 20:21:12",
    "allTimeSeconds":7.1029908657073975.
    "storage_link":"link for download"
    "storage_file_name":"Storage file name"
    "storage_file_id":"Storage file ID"
    "hash":"File hash"
}
                            
JSON Response parameter description
Parameter Description
startTime Start time of the request.
status Status code of the API request. If successful status = 200.
code Status code of the API request operation.
200 Success
404 Missing url or hrml param
405 Element not Found
406 Could Not Take Screenshot
407 Process Failed
408 Wrong parameters
409 Quota problem
error If code is 4XX - Description of the error.
pdf base64 endcoded pdf data.
screenShot *optional base64 endcoded screenshot in png format.
plan_limit Current subscription plan maximum API Calls.
remaining_limit Remaining API Calls.
endTime End time of the request.
allTimeSeconds All time of the request in seconds.
storage_link *optional Download link valid 30 Days or until the file is deleted by the user.
storage_file_name *optional Storage file name.
storage_file_id *optional Storage file ID.
hash *optional File hash.

Endpoint

GET POST https://pdfmatrix.com/api/v1/get
Parameter Description Options Default
api_token API access token. required
url The URL of the web page that you want to capture. required if html is empty
html Raw HTML string of a page that you want to capture.
Use POST for large HTML.
required if url is empty
millisecondsToWait Delay the taking of a screenshot. 0
windowWidth Browser window width in pixels 1600
windowHeight Browser window height in pixels 800
media CSS media type. screen
print
screen
click You can specify clicks on the page.
Example: click='#selector1'
waitUntilNetworkIdle Some websites lazy-load additional resources via ajax or use webfonts, which might not be loaded in time for the screenshot. Set waitUntilNetworkIdle=true to wait for a period of 500 ms with no network activity before taking the screenshot, ensuring all additional resources are loaded. true
fullPage Make single page pdf with fullpage height. true
dismissDialogs Javascript pop ups such as alerts, prompts and confirmations cause rendering of the site to stop, which leads to an empty screenshot. dismissDialogs=true automatically closes such popups allowing the screenshot to be taken. true
showBackground By default, the resulting PDF will show the background of the html page. If you don't want the background to be included you can set showBackground=false true
return Return JSON response or PDF stream or Download link. json
pdf
download
storage_link
json
returnParams Return request parameters. false
returnScreenshot Return screenshot of the page. base64 encoded png image. false
cookies You can add cookies to the request to the given url.
Example: ['Cookie-Key' => 'Cookie-Value']
cookieDomain You can specify the domain to register cookies to, if necessary.
extraHTTPHeaders Send custom HTTP headers.
Example: ['Header-Name' => 'Header-Value']
username Provide credentials for HTTP authentication.
password Provide credentials for HTTP authentication.
paperWidth PDF Paper Width in pixels.
paperHeight PDF Paper Height in pixels.
paperFormat PDF Paper Format. Letter 8.5in x 11in
Legal 8.5in x 14in
Tabloid 11in x 17in
Ledger 17in x 11in
A0 33.1in x 46.8in
A1 23.4in x 33.1in
A2 16.54in x 23.4in
A3 11.7in x 16.54in
A4 8.27in x 11.7in
A5 5.83in x 8.27in
A6 4.13in x 5.83in
If fullPage=false
Default Letter
marginTop Paper margins in mm, defaults to none.
marginRight Paper margins in mm, defaults to none.
marginBottom Paper margins in mm, defaults to none.
marginLeft Paper margins in mm, defaults to none.
headerHtml HTML template for page header. It should have a valid markup and can contain elements with classes pageNumber, totalPages, url, title or date.
Example:
Page <span class="pageNumber"></span> of <span class="totalPages"></span>
footerHtml HTML template for page footer. It should have a valid markup and can contain elements with classes pageNumber, totalPages, url, title or date.
Example:
Page <span class="pageNumber"></span> of <span class="totalPages"></span>
landscape Paper orientation. true
false
pages Paper ranges to print, e.g., 1-5, 8, 11-13. Defaults to the empty string, which means print all pages.
browserLang You can use this option to change the language of the browser, in order to load a page in a specific language.
Example: en-GB
userAgent If you want to set the user agent when taking the screenshot.
deviceScaleFactor You can also capture the webpage at higher pixel densities by passing a deviceScaleFactor value of 2 or 3. This mimics how the webpage would be displayed on a retina/xhdpi display.
mobile You can emulate a mobile view with the mobile and touch settings. mobile will set the display to take into account the page's meta viewport. true
false
touch touch will set the browser to emulate touch functionality, hence allowing spoofing for pages that check for touch. true
false
autoScroll Automatically scroll the page to bottom with one screen until the bottom is reached. true
false
false
autoScrollWait Wait XXX miliseconds between scrolling. 10
autoScrollBackToTop Automatically scroll back to top. true
false
false
autoScrollWaitEnd Wait XXX miliseconds when at the bottom.
ignoreHTTPSErrors Choose whether or not to ignore HTTPS errors during navigation. true
false
false
disableJavascript Choose whether or not to enable JavaScript on the page. true
false
false
grayscale Render document with css grayscale filter. true
false
false
documentName Document name. pdfmatrix-[timestamp].pdf

Endpoint

GET https://pdfmatrix.com/api/v1/listmyfiles
Parameter Description Options Default
api_token API access token. required
Example JSON Response.
                            {
  "status": 200,
  "code": 200,
  "result": [
    {
      "id": 6,
      "user_id": 1,
      "file_name": "pdfmatrix_1578993957.pdf",
      "store_until": "2020-02-14",
      "url": "https:\/\/pdfmatrix.com",
      "html": "",
      "download_link": "https:\/\/pdfmatrix.com\/api\/v1\/getfile\/[HASH]",
      "hash": "[HASH]",
      "created_at": "2020-01-14 09:26:05",
      "updated_at": "2020-01-14 09:26:05"
    },
    {
      "id": 5,
      "user_id": 1,
      "file_name": "pdfmatrix_1578993957.pdf",
      "store_until": "2020-02-14",
      "url": "https:\/\/pdfmatrix.com",
      "html": "",
      "download_link": "https:\/\/pdfmatrix.com\/api\/v1\/getfile\/[HASH]",
      "hash": "[HASH]",
      "created_at": "2020-01-14 09:26:05",
      "updated_at": "2020-01-14 09:26:05"
    }
  ]
}
                            

Endpoint

GET https://pdfmatrix.com/api/v1/getfile/[HASH]
Parameter Description Options Default
hash File hash to be downloaded. required
Response: PDF Stream or JSON with error message:
                            {
  "status": 200,
  "code": 404,
  "message": "File is missing."
}
                            

Endpoint

GET https://pdfmatrix.com/api/v1/deletefile
Parameter Description Options Default
api_token API access token. required
id File ID to be deleted. required
Response: JSON with status code / message:
                            {
  "status": 200,
  "code": 404,
  "message": "File is missing."
}
                            
                            {
  "status": 200,
  "code": 200
}

Endpoint

GET https://pdfmatrix.com/api/v1/user
Parameter Description Options Default
api_token API access token. required
Response: JSON user information:
{
  "id": 1,
  "name": "[NAME]",
  "email": "[MAIL]",
  "api_token": "[TOKEN]",
  "created_at": "",
  "updated_at": "",
  "plan_limit": 100,
  "remaining_limit": 100,
  "due_date": ""
}