Generate PDFs via API
const axios = require('axios');
const options = {
method: 'POST',
url: 'https://text-to-anything.p.rapidapi.com/generatePDF',
headers: {
'x-rapidapi-key': '{Your-RapidAPI-Key}',
'Content-Type': 'application/json'
},
data: {
html: '<h1>Hello world!</h1>',
format: 'A4',
landscape: false,
margin: 10,
marginRight: 5,
marginLeft: 5
}
};
const response = await axios.request(options);
console.log(response.data);
Inside of the body you have the following options:
Option | Type | Description |
---|---|---|
html | string | The HTML content for the body. |
header | string | The HTML content for the header. |
footer | string | The HTML content for the footer. |
format | string | Can be one of the following: A1, A2, A3, A4, A5, A6, Letter, Legal, Tabloid or Ledger. |
landscape | string | Should the PDF be in landscape mode? (default: false) |
margin | number | The margin of the PDF in pixels. (default: 5) |
marginLeft | marginTop | marginRight | marginBottom | number | A specific margin of the PDF in pixels. (default: 5) |
Output
The API will respond with the file.