Welcome to the OpexPDF API documentation. All the info you need to use and integrate the API into your software can be found here. Be sure to check out all examples!
If you still have any questions, please feel free to contact support@opexpdf.com!
To perform your first request, take the following steps:
https://api.opexpdf.com/conversion/html
X-Api-Key: PDF-000000-0000-0000-0000000000 <-- replace with the key from your account
{ "bodyHtmlContent": "<p>Hello world!</p>", "options": { "title": "Hello world!", "paperOrientation": "Portrait", "paperSize": "A4", "marginLeft": 1, "marginRight": 1, "marginBottom": 1, "marginTop": 1 } }
After you sign up, you can create "API Access Keys", unique keys bound to your account to perform conversions. When performing a conversion, you need to specify such an API key in the headers of the HTTP-request:
X-Api-Key: PDF-00000000-0000-0000-0000-000000000000
You can define as many API Access keys as you would like. Usage statistics are available for each separate key.
When you send a conversion request to the API to convert HTML to PDF, you need to specify the details we need to create your PDF document. You can specify this in the request body, formatted as JSON. The table below contains all properties the body can have when performing a conversion.
Property | Type | Description | Default |
---|---|---|---|
bodyHtmlContent | string | Sets the complete HTML code that needs to be converted. Required. | "" |
headerHtmlContent | string | Sets the HTML code for the header. See Headers and footers for more information about headers and footers. | null |
footerHtmlContent | string | Sets the HTML code for the footer. See Headers and footers for more information about headers and footers. | null |
options | object | Sets other conversion options. See All options for more information about headers and footers. | null |
Send your request as a POST to:
https://api.opexpdf.com/conversion/html
When you send a conversion request to the API to convert a URL to PDF, you need to specify the details we need to create your PDF document. You can specify this in the request body, formatted as JSON. The table below contains all properties the body can have when performing a conversion.
Property | Type | Description | Default |
---|---|---|---|
url | string | The URL of the website you want to convert. Required. | "" |
options | object | Sets other conversion options. See All options for more information about headers and footers. | null |
Send your request as a POST to:
https://api.opexpdf.com/conversion/url
All requests to the API are rate limited based on your current subscription plan:
Subscription plan | Rate limit |
---|---|
Basic | 60 requests / minute |
Free | 2 requests / minute |
Professional | 120 requests / minute |
Enterprise | 120 requests / minute |
On every request made, we will check the number of requests performed during the minute before. If your subscription plan's limit has been exceeded, the API will return an error "429: Too Many Request". See the section about API error codes for more details.
When your conversion request succeeds, the API will return the converted pdf document and the typical "200 OK" http response status code. However, when the request fails one of the statuscodes below will be returned:
Status code | Message | Description |
---|---|---|
401 | Unauthorized | No valid API access key was found in the request headers. |
403 | Forbidden | You don't have access to this resource. |
429 | Too many requests | You have exceeded your subscription plan's requests per minute limit or you have exceeded your monthly request quotum. A Retry-After is added to the response. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 for more information. |
Following RFC7807 all errors contain the error details in the response body. An example response for when you forget to include a valid API access key would be:
{
"type": "https://tools.ietf.org/html/rfc7235#section-3.1",
"title": "Unauthorized",
"status": 401,
"traceId": "|19ff80b6-4076a96ebc142c99."
}
Please include these details if possible when contacting our support team.
If you are interested in the usage statistics for the current billing period, you can get these by executing the following GET-request:
https://api.opexpdf.com/usage
X-Api-Key: PDF-000000-0000-0000-0000000000 <-- replace with the key from your account
The API will respond with the following:
{
"conversionsTotal": 1000,
"conversions": 553,
"conversionsRemaining": 447
}
OpexPDF supports a great number of predefined page sizes; the default is set to A4. See the list below for all predefined sizes.
Property | Values | Default |
---|---|---|
options.paperSize | A2 , A3 , A3Extra , A3ExtraTransverse , A3Rotated , A3Transverse , A4 , A4Extra , A4Plus , A4Rotated , A4Small , A4Transverse , A5 , A5Extra , A5Rotated , A5Transverse , A6 , A6Rotated , APlus , B4 , B4Envelope , B4JisRotated , B5 , B5Envelope , B5Extra , B5JisRotated , B5Transverse , B6Envelope , B6Jis , B6JisRotated , BPlus , C3Envelope , C4Envelope , C5Envelope , C65Envelope , C6Envelope , CSheet , DLEnvelope , DSheet , ESheet , Executive , Folio , GermanLegalFanfold , GermanStandardFanfold , InviteEnvelope , IsoB4 , ItalyEnvelope , JapaneseDoublePostcard , JapaneseDoublePostcardRotated , JapanesePostcard , JapanesePostcardRotated , Ledger , Legal , LegalExtra , Letter , LetterExtra , LetterExtraTransverse , LetterPlus , LetterRotated , LetterSmall , LetterTransverse , MonarchEnvelope , Note , Number10Envelope , Number11Envelope , Number12Envelope , Number14Envelope , Number9Envelope , PersonalEnvelope , Prc16K , Prc16KRotated , Prc32K , Prc32KBig , Prc32KBigRotated , Prc32KRotated , PrcEnvelopeNumber1 , PrcEnvelopeNumber10 , PrcEnvelopeNumber10Rotated , PrcEnvelopeNumber1Rotated , PrcEnvelopeNumber2 , PrcEnvelopeNumber2Rotated , PrcEnvelopeNumber3 , PrcEnvelopeNumber3Rotated , PrcEnvelopeNumber4 , PrcEnvelopeNumber4Rotated , PrcEnvelopeNumber5 , PrcEnvelopeNumber5Rotated , PrcEnvelopeNumber6 , PrcEnvelopeNumber6Rotated , PrcEnvelopeNumber7 , PrcEnvelopeNumber7Rotated , PrcEnvelopeNumber8 , PrcEnvelopeNumber8Rotated , PrcEnvelopeNumber9 , PrcEnvelopeNumber9Rotated , Quarto , Standard10x11 , Standard10x14 , Standard11x17 , Standard12x11 , Standard15x11 , Standard9x11 , Statement , Tabloid , TabloidExtra , USStandardFanfold , Custom | A4 |
In case you need to set a custom papersize, you need to set the paperSize
property to Custom
and specify the papersize manually:
Property | Type | Values | Default |
---|---|---|---|
options.customPaperHeight | double | The paper height in millimeters. | 0 |
options.customPaperWidth | double | The paper width in millimeters. | 0 |
OpexPDF supports a lot of other options when converting HTML to PDF documents. The table below contains all properties the options
-object can have when performing a conversion.
Property | Type | Description | Default |
---|---|---|---|
author | string | PDF Document Author meta-data. | "" |
createPdfFormsFromHtml | bool | Turns all Html forms elements into editable PDF forms. | true |
cssMediaType | string | Sets which stylesheet media type to use. Possible values: Screen , Print | Screen |
customCssUrl | string | Allows a custom CSS style-sheet to be applied to Html before rendering. | null |
customPaperHeight | integer | Sets the paper height in millimeters. Ignored unless PaperSize is set to Custom . | 0 |
customPaperWidth | integer | Sets the paper width in millimeters. Ignored unless PaperSize is set to Custom . | 0 |
dpi | integer | Printing output DPI. 300 is standard for most print jobs. Higher resolutions produce clearer images and text, but also larger PDF files. | 300 |
enableJavaScript | bool | Enables JavaScript and Json to be executed before the page is rendered. Ideal for printing from Ajax / Angular Applications. | true |
firstPageNumber | integer | First page number to be used in PDF headers and footers. | 1 |
fitToPaperWidth | bool | Where possible, shrinks the PDF content to 1 page of paper width. This applies when the PDF content is too wide for the given PaperSize (given that 1 HTML pixel = 1 DPI). | true |
footerHeight | double | The height of the footer. Measured in millimeters. Ignored when there is no footer to render. | 20 |
grayScale | bool | Outputs a black-and-white PDF | false |
headerHeight | double | The height of the header. Measured in millimeters. Ignored when there is no header to render. | 20 |
inputEncoding | string | The input character encoding. Possible values: UTF8 , UTF7 , UTF32 , Unicode , BigEndianUnicode , ASCII | UTF8 |
jpegQuality | integer | Quality of any image that must be re-sampled. 0-100 | 90 |
marginBottom | double | Bottom paper margin in millimeters. Set to zero for border-less and commercial printing applications. | 25 |
marginLeft | double | Left paper margin in millimeters. Set to zero for border-less and commercial printing applications. | 25 |
marginRight | double | Right paper margin in millimeters. Set to zero for border-less and commercial printing applications. | 25 |
marginTop | double | Top paper margin in millimeters. Set to zero for border-less and commercial printing applications. | 25 |
paperOrientation | string | The PDF paper orientation. Possible values: Portrait , Landscape | Portrait |
paperSize | string | Set an output paper size for PDF pages. See here for a complete list of possible values | A4 |
printHtmlBackgrounds | bool | Prints background-colors and images from Html | true |
renderDelay | integer | Milliseconds to wait after Html is rendered before printing. This can use useful when considering the rendering of JavaScript, Ajax or animations. | 0 |
title | string | PDF Document Name and Title meta-data. | "" |
viewPortHeight | integer | Defines a virtual screen height used to render HTML to PDF. Measured in pixels. | 1024 |
viewPortWidth | integer | Defines a virtual screen width used to render HTML to PDF. Measured in pixels. | 1280 |
zoom | integer | The zoom level in %. Enlarges the rendering size of Html documents. | 100 |
To integrate easily into your application, you can use our Swagger/OpenAPI file that describes the API. The file can be found here.
With this file, you can easily generate code in the language of your choice that you can use to call the API. Generators are available for many languages, but these are some of the more common ones:
Name | Url | Language(s) |
---|---|---|
ng-openapi-gen | https://github.com/cyclosproject/ng-openapi-gen | Angular |
NSwagStudio | https://github.com/RicoSuter/NSwag/wiki/NSwagStudio | .NET |
openapi-generator | https://github.com/OpenAPITools/openapi-generator | Lots of different languages |