PDF from HTML

I want to Prevent Images from Breaking Across Pages in HTML to PDF

You want to generate a PDF from HTML without having images split awkwardly across pages.

Why This Happens

When converting HTML to PDF, especially in long documents, browsers or PDF renderers may automatically break content (like images or <div>s) across pages. This results in visual issues where a single image may appear partially on one page and continue on the next.

How to Keep Images (or Elements) Intact

To prevent this, you’ll use a CSS style that instructs the PDF renderer not to break certain elements across pages.

Step-by-Step Fix

Use the break-inside:avoid CSS Rule: Add a <style> tag in the HTML head with a rule that prevents elements (like <div>, <p>, or <img>) from splitting. Inject the CSS Using Profiles: Use the profiles parameter to inject the style into your HTML during conversion.

Example: Preventing Breaks in Zapier or Make

Zapier or Integromat/Make Users: Set the Profiles field to:

{"HTMLCodeHeadInject":"<style> @media print { div,p { break-inside: avoid !important; } } </style>"}

This will inject the appropriate CSS when converting from HTML.

For Developers (API)

When using the /pdf/convert/from/html or /pdf/convert/from/url endpoints, include the profiles parameter like this:

{
  "profiles": "{'HTMLCodeHeadInject':'<style> @media print { div,p { break-inside: avoid !important; } } </style>'}"
}

This ensures the CSS rule is applied during PDF generation.

Applies To:

Helpful Tips

  • Always test the final PDF to confirm formatting appears as expected.
  • Combine this method with margin settings or custom page breaks for better layout control.

Still Need Help? Contact Support

To help us assist you faster, please send us:

  • What you’re trying to do
  • Your platform (API, Zapier, Make, etc.)
  • Any input files, URLs, or sample data
  • The exact error message (if you saw one)
  • A screenshot or brief description of what went wrong

How to Convert HTML to PDF with a Custom Page Size

You want to generate a PDF from HTML with a specific page size—such as 4 inches by 6 inches—instead of the default A4.

How to Set a Custom PDF Page Size

To generate a PDF at a custom size, use the paperSize parameter in your API call or integration.

Example: to create a 4x6 inch PDF, set:

"paperSize": "4in 6in"

You can also use other units:

  • px200px 300px
  • mm100mm 150mm
  • cm10cm 15cm
  • in4in 6in

API Example

Here’s a sample API request to convert HTML to a 4x6 inch PDF:

POST /v1/pdf/convert/from/html HTTP/1.1
Host: api.pdf.co
x-api-key: YOUR_API_KEY
Content-Type: application/json

{
    "html": "<h1>Hello World!</h1><a href='https://pdf.co'>Go to PDF.co</a>",
    "name": "newDocument.pdf",
    "mediaType": "print",
    "margins": "0",
    "paperSize": "4in 6in",
    "orientation": "Portrait",
    "printBackground": false
}

Zapier

In the HTML to PDF Converter action:

  1. Find Page Size Override
  2. Enter 4in 6in

Make / Integromat

In the PDF.co Convert HTML to PDF module:

  1. Set Paper SizeCustom
  2. Enter 4in 6in in the size field

Helpful Tips

  • Always include the unit (e.g., in, mm, px) in paperSize
  • Use margins: 0 for full-page layouts
  • Use printBackground: true if your HTML needs background styles

Still Need Help? Contact Support

To help us assist you faster, please include:

  • What you’re trying to do (e.g., convert a web form to 4x6 PDF)
  • Your platform (API, Zapier, Make, etc.)
  • Sample HTML or file
  • Any error messages
  • Screenshots or a brief issue summary

How to Keep Form Controls When Converting HTML to PDF

When you convert an HTML page to PDF, form controls like input fields, checkboxes, and dropdowns appear as static visuals but are not interactive.

Why This Happens

The PDF format doesn’t automatically convert HTML form elements into interactive form fields. They’re rendered as plain graphics rather than fillable fields.

How to Make PDF Forms Fillable

To add interactive form controls, you need to create form fields in the PDF after converting from HTML.

2-Step Workflow:

  1. Convert the HTML to PDF Use the /pdf/convert/from/html API or your preferred HTML-to-PDF tool to generate the static PDF.

  2. Add Form Fields to the PDF Use the /pdf/edit/add API endpoint to insert form fields like textboxes, checkboxes, and dropdowns into the PDF.

Platform-Specific Guides

Helpful Tips

  • Use PDF.co’s built-in PDF Inspector Tool to visually test field placement.
  • Use exact coordinates for better precision when placing fields.

Still Need Help? Contact Support

To help us assist you faster, please share:

  • What you’re trying to do
  • Your platform (API, Zapier, Make, etc.)
  • Input files or sample HTML
  • Any error messages or logs
  • A screenshot or brief description of the issue

The Issue

You want to add clickable navigation links inside a PDF—such as a table of contents that jumps to a section, or internal links between parts of a long document—but the links aren’t working as expected.

Why This Happens

When converting HTML to PDF, some users may not realize that internal anchor links (#marker) require properly placed markers (<a name="...">) in the HTML for the PDF converter to recognize them. Without these, the links won’t work in the output file.

To add internal navigation links to your PDF:

  1. Add a Marker Where You Want to Jump

Use this in your HTML:

<a name="marker1"></a>
  1. Add a Link to That Marker

Use this in your HTML:

<a href="#marker1">Jump to Marker 1</a>

Example: Create a Table of Contents

Here’s a sample HTML that adds navigation to two sections:

<!-- Navigation links at the top -->
Navigation: 
<a href="#section1">Section 1</a> | 
<a href="#section2">Section 2</a>

<!-- Target sections -->
<a name="section1"></a>
<h1>Section 1</h1>
<p>Content for section 1...</p>

<a name="section2"></a>
<h2>Section 2</h2>
<p>Content for section 2...</p>

What Happens in the PDF

Once converted using the HTML to PDF tool, the output PDF will preserve these internal links. Clicking on “Section 1” or “Section 2” in the navigation will jump directly to the respective areas—just like in the original HTML document.

Helpful Tips

Double-check that both the link (href="#...") and the marker (name="...") match exactly.

  • Ensure correct HTML syntax—mismatched quotes or missing closing tags can break links.
  • Test in a browser first to confirm links are functioning before converting.

Still Need Help? Contact Support

To get faster support, send us:

  • A description of what you’re trying to do
  • Your platform (API, Zapier, Make, etc.)
  • Any sample input files or URLs
  • The error you’re seeing (if any)
  • Screenshots or a brief explanation of what didn’t work

I Want to Avoid Page Breaks in My PDF

You may be experiencing unwanted page breaks in your generated PDF—such as a section of text or a table being split across two pages.

Why This Happens

By default, PDFs are set to render in A4. When your content exceeds the default page height, it causes automatic page breaks.

How to Avoid Page Breaks

To prevent this, you can customize the page size using the paperSize parameter. This ensures the page is long enough to hold all your content without forcing a break.

Example: Use a Custom Page Size

To avoid page breaks and allow more vertical space, increase the page length. Set the paperSize like this:

{
  "paperSize": "6in 15in"
}

This sets the page width to 6 inches and the height to 15 inches—enough space for taller content like long tables or paragraphs.

Helpful Tips

  • Adjust paperSize according to your content length.
  • Use longer page heights to accommodate full content without breaks.
  • If using async: true, monitor job status for large files.

Still Need Help? Contact Support

Send us the following to speed things up:

  • What you’re trying to do Your platform (API, Zapier, Make, etc.)
  • Any input files, URLs, or sample data
  • The exact error message (if any)
  • A screenshot or brief description of what went wrong

I Want to Force a New Page in the Output PDF

You want to make sure that certain content in your PDF always starts on a new page, but currently, everything appears continuously without page breaks.

Why It Happens

When you’re generating PDFs from HTML or HTML templates, content flows naturally like a webpage—without automatic page breaks—unless you explicitly tell it where to break using specific CSS rules.

How to Force a New Page

To force a page break in your PDF output, use the following CSS property in your HTML:

page-break-after: always;

This ensures that any element it’s applied to will force the next content to start on a new page.

Examples

Example 1 — Using a <div> tag:

<div style="display:block; clear:both; page-break-after:always;"></div>

Example 2 — Using a <p> tag:

<p style="display:block; clear:both; page-break-after:always;"></p>

These tags act as “invisible” page breaks in your layout, ensuring that whatever comes next starts on a new page in the final PDF.

Helpful Tips

  • Apply the style to a <div> or <p> between sections you want to separate.
  • Combine with layout styles like clear:both to prevent content from overlapping.

Still Need Help? Contact Support

To help us assist you better, please include:

  • What you’re trying to do (e.g. generate invoice pages separately)
  • Your platform (API, Zapier, Make, etc.)
  • Sample input HTML or output PDF
  • A screenshot or description of what went wrong
  • Any error messages, if applicable

You’re trying to add a clickable link (like a URL or email address) inside a PDF that was originally generated from HTML.

Why This Happens

When you convert HTML to PDF, the PDF is generated as a static document. If the original HTML didn’t include the link as an anchor tag (<a>), or if you want to place a new link in a specific position after conversion, it won’t exist in the PDF by default. That’s why adding the link requires a second step after conversion.

To insert a link, you’ll use two steps:

  1. Convert HTML to PDF

Use the /pdf/convert/from/html endpoint to generate the PDF from your HTML content. 2. Add the Link to the PDF

Once the PDF is generated, use the /pdf/edit/add endpoint to insert the clickable link. You’ll need to specify the x and y coordinates on the PDF where the link should appear.

Tip:

Use the PDF Inspector Tool to visually identify the coordinates (x, y) of where you want to place the link.

Example Workflow

Let’s say you want to generate a PDF from HTML and then place a clickable link at the bottom right of the first page:

  1. Convert HTML to PDF

Call /pdf/convert/from/html with your raw HTML or a URL.

  1. Add the Link

Call /pdf/edit/add with:

  • The URL of the newly created PDF.
  • The coordinates where you want the link.
  • The link itself (e.g., “link”: “https://yourwebsite.com”).
  • The target page number (e.g., page 1).

Helpful Tips

  • You can add multiple links in one request by using an array of annotations.
  • Use async: true for large PDFs to avoid timeout.
  • Make sure the coordinates you select fall within the content area of the page.

Still Need Help? Contact Support

To help us assist you faster, please include:

  • A short description of your use case
  • Your platform (API, Zapier, Make, etc.)
  • Input file URL or sample HTML
  • The exact error (if any)
  • Screenshot or description of where you want to place the link

PDF from CSV

How to Convert a Specific Google Sheets Worksheet to PDF

You’re Trying to Convert Just One Worksheet

You want to export only one worksheet from a Google Sheets document as a PDF file—not the entire spreadsheet.

How to Convert a Specific Worksheet

To convert a single worksheet from Google Sheets to PDF, you’ll need to construct a custom download URL.

Use the following format:

https://docs.google.com/spreadsheets/d/[spreadsheet_id]/export?format=[file_format]&gid=[worksheet_id]

Where:

  • [spreadsheet_id]: The unique ID of your Google Sheets document (found in the URL).
  • [file_format]: The format you want to export to — in this case, use “pdf”.
  • [worksheet_id]: The specific gid (worksheet ID) of the tab you want to export.

Example

If you want to download a worksheet with:

  • Spreadsheet ID: 12345
  • Worksheet ID (gid): 6789

Your URL will look like this:

https://docs.google.com/spreadsheets/d/12345/export?format=pdf&gid=6789

Opening this link in a browser or using it in a PDF.co task will generate a PDF of just that worksheet.

Helpful Tips

  • Make sure the Google Sheet is shared publicly or with anyone with the link so the system can access it.
  • To automate this in workflows, pass the export link dynamically using spreadsheet/worksheet metadata.

Still Need Help? Contact Support

To help us assist you faster, please include:

  • A brief summary of what you’re trying to achieve
  • Your platform (API, Zapier, Make, etc.)
  • Your input files or the export link you’re using
  • Any error messages you’ve received
  • Screenshots (if possible) for clarity

I Want to Convert Google Sheets/Excel to PDF

You’re trying to convert a Google Sheet or Excel file into a PDF—possibly to share, archive, or prepare a report. However, you’re not sure how to get it formatted correctly, or how to convert specific sheets or orientation (landscape vs portrait).

How to Convert Google Sheets/Excel to PDF

To convert a spreadsheet to a PDF, you’ll typically follow one of two methods:

  • Use an automation platform like Zapier or Make
  • Use a direct download link or API call

Zapier

Use these step-by-step guides to set up automated spreadsheet-to-PDF conversions:

Integromat / Make

If you’re using Make (formerly Integromat), follow this resource:

Web API Code Samples

If you’re working with the PDF.co API directly, these code samples will help:

You can also convert Google Sheets to PDF using a simple direct link:

https://docs.google.com/spreadsheets/d/INSERT_FILE_ID/export?format=pdf&portrait=false

Replace INSERT_FILE_ID with your sheet’s actual ID. To force landscape, add &portrait=false to the URL.

Helpful Tips

  • Use Zapier/Make to automate recurring conversions.
  • In API mode, control page size, margins, and orientation.
  • Make sure your spreadsheet is publicly accessible or properly authenticated if you’re using a URL.

Still Need Help? Contact Support

To help us assist you faster, please include:

  • What you’re trying to do
  • The platform you’re using (Zapier, Make, API, etc.)
  • A sample file or link
  • Any error message you encountered
  • Screenshot or brief description of the issue