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>'
  }
})

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.

PARAMETERTYPEDEFAULTDESCRIPTION
api_keystringA 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
htmlstringRaw HTML content to convert to PDF. Either html or url must be provided, but not both.
urlstringA valid URL pointing to a webpage to convert to PDF. Either html or url must be provided, but not both.
testbooleanIf 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_pagebooleanIf true, all content will be rendered on a single page.
landscapebooleanIf true, the PDF will be generated in landscape mode.
print_backgroundbooleanIf true, prints background graphics in the PDF.
scalenumber1Scaling 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:
  • Standard formats: Letter, Legal, Tabloid, Ledger
  • International sizes: A0, A1, A2, A3, A4, A5, A6
Alternatively, you can provide custom dimensions as an object with width and height in inches.
margins
numberor{ top: number, right: number, bottom: number, left: number }
0.39Margins for the PDF in inches. If a single number is provided, it will be applied to all sides. Margins must be higher than 0.
filenamestring"file.pdf"The filename for the generated PDF.
owner_passwordstringOwner password for encrypting the PDF. Owner has all permissions enabled.
user_passwordstringUser password for restricting access to the PDF.
permissionsstring[]
Array of permissions to restrict PDF for users.
  • print – Allows printing the document.
  • modify – Allows modifications to the document.
  • copy – Allows copying text or images from the document.
  • annotate – Allows adding comments or annotations.
  • fill_forms – Allows filling in interactive form fields.
  • accessibility – Allows screen reader access.
  • assemble – Allows assembling the document - insert, rotate, delete pages, bookmarks, thumbnails.
headerstringHTML 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.
stringHTML 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>