Documentation
Introduction
Welcome to the PDFNode, a powerful and easy-to-use service that allows you to generate high-quality PDFs from HTML content.
Whether you need to create invoices, reports, or printable web pages, our API provides a seamless way to convert your HTML into professional PDFs.
Quick Start
To start using the PDFNode, follow these steps:
1. Get Your API Key
Sign Up on our platform and retrieve your API key from the dashboard.
2. Send a Request
Make a POST request to our API endpoint /api/convert
with your HTML content
const pdf = await axios('https://pdfnode.com/api/convert', {
method: 'POST',
data: {
api_key: 'YOUR_API_KEY',
html: '<html><body><h1>First converted PDF!</h1></body></html>'
}
})
url
of a website: url: 'https://wikipedia.org'
Test Mode
Test mode allows you to try out the PDF conversion process without consuming your usage quota.
When the test parameter is set to true
, the generated PDF will include a watermark indicating that it was created in test mode.
const pdf = await axios('https://pdfnode.com/api/convert', {
method: 'POST',
data: {
api_key: 'YOUR_API_KEY',
html: '<html><body><h1>PDF with test watermark</h1></body></html>'
test: true
}
})
Parameters
The following table outlines the parameters that can be included in a conversion request.
PARAMETER | TYPE | DEFAULT | DESCRIPTION |
---|---|---|---|
api_key | string | A required key used for authentication. This key verifies the user's access to the API and must be included in every request. You can retrieve your API key from the dashboard | |
html | string | Raw HTML content to convert to PDF. Either html or url must be provided, but not both. | |
url | string | A valid URL pointing to a webpage to convert to PDF. Either html or url must be provided, but not both. | |
test | boolean | If true , a watermark will be applied to the generated PDF, but it will not count towards your used conversions. Ideal for testing purposes. | |
range | { from: number, to: number } | Page range to include in the PDF, from and to must be integers starting from 1, and from must be less than to . | |
single_page | boolean | If true , all content will be rendered on a single page. | |
landscape | boolean | If true , the PDF will be generated in landscape mode. | |
print_background | boolean | If true , prints background graphics in the PDF. | |
scale | number | 1 | Scaling factor for the pages. Must be between 0.1 and 2 . |
format | stringor{ width: number, height: number } | "A4" | Format of the pages. Can be a predefined string or custom dimensions in inches. Supported formats include:
width and height in inches. |
margins | numberor{ top: number, right: number, bottom: number, left: number } | 0.39 | Margins for the PDF in inches. If a single number is provided, it will be applied to all sides. Margins must be higher than 0 . |
filename | string | "file.pdf" | The filename for the generated PDF. |
owner_password | string | Owner password for encrypting the PDF. Owner has all permissions enabled. | |
user_password | string | User password for restricting access to the PDF. | |
permissions | string[] | Array of permissions to restrict PDF for users.
| |
header | string | HTML content to be added as a header on each page of the PDF. This can include text, images, or dynamic values such as page numbers. | |
footer | string | HTML content to be added as a footer on each page of the PDF. Similar to the header, this can include additional page information, dates, or branding. |
CSS
The styling of the generated PDF can be customized using CSS. You can apply inline styles within the HTML content, use external stylesheets, or include styles directly within a <style>
tag.
For convenience, you can also use popular utility-first frameworks like Tailwind CSS by importing it from a CDN. To include Tailwind in your HTML, add the following inside the <head>
of your document - optional theming can be added as well:
<head> <script src="https://cdn.tailwindcss.com"></script> <script> tailwind.config = { theme: { extend: { colors: { primary: '#148f8b', } } } } </script> </head>
This allows you to use Tailwind classes for styling without needing any additional setup:
<body> <h1 class="text-3xl font-bold text-primary"> I'm styled by Tailwind CSS! </h1> </body>