Documentation

Authentication

Authentication is done by simply passing apiKey parameter to the request, using GET or POST method. You will get the apiKey parameter to your email after the registration.

Your "apiKey" is private information, so don't expose it publicly!

A simple example could be like this:

https://api.html2pdf.app/v1/generate?url=https://example.com&apiKey={your-api-key}

Parameters

Note that parameters should be URL encoded when sending a GET request.
ParameterTypeDescriptionDefault
htmlstringHTML code or website URL you want to generate(required)
apiKeystringYour api key which you will get after registration, and can find in a dashboard(required)
callBackUrlstringGenerates document in a background and sends result in your callback url.

We will send generated pdf document (encoded with base64) to your provided callback url in this structure:
{"document": "..."}
null
statestringThis is custom parameter provided by the user which will be sent to the callBackUrl when document is generated.null
landscapebooleanActivates landscape modefalse
formatstringFormat of the document, can have one of values:
Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
A4
widthintegerCustom width of the pdf size (use in conjunction with height parameter)null
heightintegerCustom height of the pdf size (use in conjunction with width parameter)null
marginTop
marginRight
marginBottom
marginLeft
integerEmpty spaces between the outer and the beginning of the content (integer value which is equal to pixels)0
filenamestringFilename header will be returnednull
waitForintegerParameter to wait for some time (in seconds) before generate the pdf document. It is useful if you have some javascript code running in the background after page was loaded. Available values from 0 to 10.null
mediastringUse print value to generate pdf using print mode styles, can have one of values: print, screenscreen
scalenumberDefines the scale of the pdf document content. Scale range is from0.1 to 21
headerTemplate
footerTemplate
stringParameter to provide header / footer of the page. HTML code should be provided and used in conjunction with marginTop / marginBottom to be visiblenull

Fonts

As an alternative way, you can use any font you want using Google fonts or Web fonts.

We support fonts listed bellow.

  • Andale Mono
  • Arial
  • Arial Black
  • Arial Narrow
  • Arial Unicode
  • Comic Sans MS
  • Courier New
  • Georgia
  • Impact
  • Microsoft Sans Serif
  • NotoSans
  • NotoSerif
  • Tahoma
  • Times New Roman
  • Trebuchet MS
  • Verdana
  • Webdings