# HTML to PDF

## Transform HTML to PDF

With Renda' HTML to PDF transformation API - HTML output can be converted to PDF document. Optionally the  PDF document can also password protected by using AES 256 encryption algorithm. &#x20;

{% hint style="info" %}
API calls are region specific. Please make sure you are subscribed to a specific region before making API calls.
{% endhint %}

## Ping

<mark style="color:blue;">`GET`</mark> `https://api-<region>.renda.io/v2/ping/`

This API perform a heartbeat check to verify if the configuration is all setup correctly from your application. \
\
**Region specific URLs:**\
\
Ireland(Europe): **`https://api-eu.renda.io/v2/ping`**\
North Virginia(US): **`https://api-us.renda.io/v2/ping`**\
Mumbai (Asia Pacific): **`https://api-apac.renda.io/v2/ping`**

#### Headers

| Name      | Type   | Description                                                                              |
| --------- | ------ | ---------------------------------------------------------------------------------------- |
| x-api-key | string | <p>Renda.io API Key<br><br>A valid renda.io user account is required to view API Key</p> |

{% tabs %}
{% tab title="200 Successful Ping" %}

```javascript
{
    "message": "Renda.io ping Successful"
}
```

{% endtab %}

{% tab title="403 Invalid API Key" %}

```
{
"message”:”We are unable to service your request. Things to verify: 
1) A valid API Key should be passed in ‘x-api-key’ request header parameter.
 2) An active Renda.io subscription 3) API being invoked must be Subscribed 
 using the Subscribe button in Renda developer portal. Please refer to Renda 
 documentation for more details - https://documentation.renda.io"
}
```

{% endtab %}
{% endtabs %}

## Generate PDF&#x20;

<mark style="color:green;">`POST`</mark> `https://api-<region>.renda.io/v2/generatePDF`

This API enables conversion of HTML and text documents in PDF. Optionally the generated PDF can also be encrypted \
\
Region specific URLs:\
\
Ireland(Europe): `https://api-eu.renda.io/v2/generatePDF`\
North Virginia(US): `https://api-us.renda.io/v2/generatePDF`\
Mumbai(APAC):`https://api-apac.renda.io/v2/generatePDF`

#### Headers

| Name                                        | Type   | Description                       |
| ------------------------------------------- | ------ | --------------------------------- |
| x-api-key<mark style="color:red;">\*</mark> | string | Renda API Key                     |
| Accept                                      | string | application/pdf                   |
| Content-type                                | string | application/x-www-form-urlencoded |

#### Request Body

| Name          | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| inputPayload  | string  | HTML payload to transform to PDF format                                                                                                                                                                                                                                                                                                                                                                          |
| encryptionKey | string  | Encryption key to password protect the generated PDF                                                                                                                                                                                                                                                                                                                                                             |
| landscape     | boolean | <p>Paper orientation. <br><br><strong>Defaults to false</strong></p>                                                                                                                                                                                                                                                                                                                                             |
| format        | string  | <p>Paper Format. <br><br><strong>Defaults to A4</strong><br><br>Valid Options: Letter, Legal, Tabloid, Ledger, A0,A1,A2,A3,A4,A5,A6<br><br>Letter: 8.5in X 11in<br>Legal: 8.5in x 14in<br>Tabloid: 11in x 17in<br>Ledger: 17in x 11in<br>A0: 33.1in x 46.8in<br>A1: 23.4in x 33.1in<br>A2: 16.54in x 23.4in<br>A3: 11.7in x 16.54in<br>A4: 8.27in x 11.7in<br>A5: 5.83in x 8.27in<br>A6: 4.13in x 5.83in<br></p> |
| marginTop     | string  | <p>Paper Margin top <br><strong>Defaults to blank</strong><br>Top margin, accepts values labeled with units<br><em><strong>Example: 50px</strong></em></p>                                                                                                                                                                                                                                                       |
| marginRight   | string  | <p>Paper Margin right<br><strong>Defaults to blank</strong><br>Right margin, accepts values labeled with units</p>                                                                                                                                                                                                                                                                                               |
| marginBottom  | string  | <p>Paper Margin bottom <br><strong>Defaults to blank</strong><br>Bottom margin, accepts values labeled with units<br></p>                                                                                                                                                                                                                                                                                        |
| marginLeft    | string  | <p>Paper Margin Left<br><strong>Defaults to blank</strong><br>Left margin, accepts values labeled with units</p>                                                                                                                                                                                                                                                                                                 |
| header        | string  | HTML payload for PDF header                                                                                                                                                                                                                                                                                                                                                                                      |
| footer        | string  | HTML payload for PDF footer                                                                                                                                                                                                                                                                                                                                                                                      |

{% tabs %}
{% tab title="200 A valid PDF document is returned as a success response" %}

```javascript
%PDF-1.4
%����
1 0 obj
<</Creator (Chromium)
/Producer (Skia/PDF m83)
........
....<PDF Content>...
.......
%%EOF
```

{% endtab %}

{% tab title="500 PDF Generation error will be notified via HTTP 500 errors" %}

```javascript
{
"<Error Response from Server>"
}
```

{% endtab %}

{% tab title="403: Forbidden Invalid API Key" %}

```javascript
{
"message”:”We are unable to service your request. Things to verify: 
1) A valid API Key should be passed in ‘x-api-key’ request header parameter.
 2) An active Renda.io subscription 3) API being invoked must be Subscribed 
 using the Subscribe button in Renda developer portal. Please refer to Renda 
 documentation for more details - https://documentation.renda.io"
}
```

{% endtab %}
{% endtabs %}
