Skip to main content

Convert HTML to PDF using Zapier: automate invoices from a Dropbox folder with PDF4me

20 min read
PDF4me Team

Convert HTML to PDF is a PDF4me action for Zapier that turns an HTML file into a print ready PDF. Paired with Generate Document, a five step Zap watches a Dropbox folder, merges order data into an HTML invoice template, converts the result to A4, and saves the finished PDF back to Dropbox.

Most "convert HTML to PDF" results hand you a box to drop a file into. That is fine once. It stops being fine when a new order lands every hour and somebody has to open the converter, upload, download, rename, and file the result. This walkthrough replaces that loop with five Zapier steps that run on their own, with real screenshots from a Zap that ran on 02 November 2026 and the exact field values it used.

The flow at a glance
1. New File in Folder
Dropbox trigger watching /DocGen/Orders for a new order JSON.
2. Find File
Dropbox fetches invoice-template.html from /DocGen/Templates.
3. Generate Document
PDF4me merges the order JSON into the HTML template.
4. Convert HTML to PDF
PDF4me renders the merged HTML as an A4 portrait PDF.
5. Upload File
Dropbox saves the PDF to /DocGen/Output/ with a runtime name.
The short version

Drop an order JSON into a watched Dropbox folder. Zapier picks it up within two minutes, pulls your HTML invoice template from a second folder, and hands both to PDF4me. Generate Document merges the data into the template, Convert HTML to PDF renders it at A4 with 40px margins, and Dropbox stores the result as Invoice-order-INV-2026-1042.pdf. Nobody opens a converter.

Why-Based Q&A​

Why two PDF4me actions instead of one? Generate Document does the data merge and returns HTML. Convert HTML to PDF does the rendering and page setup. Splitting them means you can change the paper size or margins without touching the template, and you can reuse the same template for a different output format later.

Why fetch the template with a separate Find File step? The trigger only carries the file that just arrived, which is the order data. The template lives somewhere stable, so step 2 reads it from /DocGen/Templates on every run. Edit the template in Dropbox and the next invoice picks it up with no Zap change.

Why set Scale to 0.8? HTML is laid out for a screen, not a page. A scale of 0.8 pulls a typical invoice table inside the A4 content width so columns do not wrap awkwardly or spill onto a second page. Raise it toward 1.0 if your template is already narrow.

Why does Print Background matter? With Print Background set to False, browsers and renderers drop CSS background colours and images, so a coloured invoice header prints blank. Set it to True and the PDF matches what the HTML looks like on screen.


What You'll Get​

Input: an order JSON dropped into a watched Dropbox folder, plus one HTML invoice template that stays put. Output: a finished A4 PDF in /DocGen/Output/, named from the order number, with a Dropbox sharing link returned by the final step.


What You Need​

  • Zapier. Open the PDF4me Zapier app. A free Zapier plan runs single step Zaps only, so this five step Zap needs a paid Zapier plan.
  • PDF4me API key. Get your API key. Connect it the first time you add a PDF4me action.
  • Dropbox with three folders: /DocGen/Orders for incoming data, /DocGen/Templates for the template, /DocGen/Output for results.
  • An HTML invoice template and a sample order. Both are below.

Grab the samples first. Put invoice-template.html in /DocGen/Templates before you build the Zap, so step 2 has something to find when you test it.


The Flow at a Glance​

  1. New File in Folder (Dropbox trigger, polls every 2 minutes).
  2. Find File (Dropbox) pulls invoice-template.html.
  3. Generate Document (PDF4me) merges the JSON into the HTML template.
  4. Convert HTML to PDF (PDF4me) renders A4 portrait at scale 0.8.
  5. Upload File (Dropbox) saves the PDF under a runtime name.

Complete flow overview​

Zapier run history showing a successful five step Zap: Dropbox New File in Folder, Dropbox Find File, Pdf4me Generate Document, PDF4me Convert HTML to PDF, and Dropbox Upload File, all with green checkmarks

A successful run on 02 November 2026. Each step reports what it passed on, which is the fastest way to spot where a failed run stopped.


Step 1: How do you watch a Dropbox folder for new orders?​

Flow so far: nothing yet, this is the trigger.

The trigger decides what starts the Zap. Point it at the folder your order data lands in, and make sure it carries the file contents forward.

  1. Add Dropbox as the trigger app and pick the New File in Folder event.
  2. Configure:
    • Space: Default
    • Folder: /DocGen/Orders
    • Include files in subfolders?: False
    • Include file contents?: Yes
    • Include sharing link?: No

New File in Folder configuration​

Dropbox New File in Folder trigger configured with Space Default, Folder /DocGen/Orders, Include files in subfolders False, Include file contents Yes, and Include sharing link No

Include file contents has to be Yes. With No, step 3 receives a file reference with no data behind it and the merge fails.

Tip. The trigger polls on a schedule, shown as 2 min in the run history, so this is near real time rather than instant. Keep the output folder outside the watched folder or the saved PDF can retrigger the Zap.


Step 2: Why fetch the template before merging?​

Flow so far: New File in Folder.

The trigger hands you the order data only. The template is a separate file in a separate folder, so you read it explicitly.

  1. Add Dropbox and pick the Find File action.
  2. Configure:
    • Space: Default
    • Folder: /DocGen/Templates
    • Include files in subfolders?: False
    • File Name: invoice-template.html
    • Include Deleted Files?: False
    • Include file contents?: Yes
    • Include sharing link?: No
    • Successful if no search results are found?: False: step run status is "stopped: halted"
    • If multiple search results are found: Return first search result

Find File configuration​

Dropbox Find File action configured with Folder /DocGen/Templates, File Name invoice-template.html, Include file contents Yes, and halt on no results

Leaving "Successful if no search results are found" on False is deliberate. A missing template halts the run instead of producing an empty PDF.


Step 3: How does Generate Document merge JSON into an HTML template?​

Flow so far: New File in Folder plus Find File.

Generate Document takes two inputs: the template from step 2 and the data from step 1. It returns the merged HTML, not a PDF.

  1. Add PDF4me and pick the Generate Document action.
  2. Configure:
    • Template File: the File output of step 2, Find File
    • Template File Name: invoice-template.html
    • Template File Type: HTML
    • Input Data Format Type: File
    • Data File: the File output of step 1, New File in Folder
    • Input Data Type: Json
    • Meta Data: leave empty
    • Keep Pdf Editable: False

Generate Document configuration​

PDF4me Generate Document action with Template File from step 2, Template File Name invoice-template.html, Template File Type HTML, Input Data Format Type File, Data File from step 1, Input Data Type Json, and Keep Pdf Editable False

Template File Type is HTML and Input Data Type is Json. Those two dropdowns are the pair people most often mismatch, and a mismatch returns the template with the placeholders still in it.

Tip. If your data arrives as a Zapier field rather than a file, switch Input Data Format Type from File to the text option and paste the JSON in. The rest of the step is unchanged.


Step 4: How do you convert HTML to PDF without losing formatting?​

Flow so far: New File in Folder plus Find File plus Generate Document.

This is the step the whole post is named after. It takes the merged HTML from step 3 and renders it, and the page setup fields here are what decide whether the result looks like the original.

  1. Add PDF4me and pick the Convert HTML to PDF action.
  2. Configure:
    • File: the File Url output of step 3, Generate Document
    • File Name: invoice.html
    • Layout: Portrait
    • Paper Size: A4 (8.27in x 11.7in)
    • Scale: 0.8
    • Margins: 40px on each side
    • Print Background: True

Convert HTML to PDF parameters​

FieldValue usedWhat it controls
FileFile Url from step 3The merged HTML. Supply either File or File URL, not both.
File Nameinvoice.htmlNames the input for the renderer. The .html extension matters.
Index File PathemptyOnly used when the input is an archive with several HTML files.
LayoutPortraitPortrait or Landscape.
Paper SizeA4 (8.27in x 11.7in)Page dimensions of the output PDF.
Scale0.8Shrinks the rendered page so wide tables fit the content width.
Margins40pxSet per side. See the note below about the field labels.
Print BackgroundTrueKeeps CSS background colours and images. False prints them blank.
PDF4me Convert HTML to PDF action configured with File Url from step 3, File Name invoice.html, Layout Portrait, Paper Size A4, Scale 0.8, four 40px margin fields, and Print Background True

Scale 0.8 with 40px margins is a safe starting point for an invoice. Print Background True is what keeps the coloured header from printing blank.

Tip. In the current Zapier app the four margin fields read Top Margin, Bottom Margin, Left Margin and Bottom Margin. The fourth box is the right margin despite its label, so fill all four in the order they appear. Setting every side to the same value, as here, sidesteps the ambiguity entirely.


Step 5: Where does the finished PDF go?​

Flow so far: New File in Folder plus Find File plus Generate Document plus Convert HTML to PDF.

The last step writes the PDF back to Dropbox and gives it a name you can trace to the order.

  1. Add Dropbox and pick the Upload File action.
  2. Configure:
    • Space: Default
    • Folder: /DocGen/Output/
    • File: the File Url output of step 4
    • Overwrite: True
    • Specify File Name: the literal text Invoice- followed by the File Name field from step 1
    • Specify File Extension: pdf
    • Include sharing link?: Yes

Upload File configuration​

Dropbox Upload File action with Folder /DocGen/Output/, File from step 4 File Url, Overwrite True, Specify File Name combining the literal Invoice- with the step 1 file name order-INV-2026-1042, Specify File Extension pdf, and Include sharing link Yes

Specify File Name mixes a literal prefix with a value from the trigger, so the output is Invoice-order-INV-2026-1042.pdf rather than a random identifier.


Run the Flow and Verify​

  1. Publish the Zap.
  2. Drop a sample order JSON into /DocGen/Orders and wait for the next poll, up to two minutes.
  3. Open Zap runs in Zapier and confirm all five steps show a green tick.
  4. Look in /DocGen/Output/ for the new PDF and open it. The header should be coloured, the table should fit the page width, and the filename should carry the order number.

What did you actually build? A document factory. The template is editable by anyone with Dropbox access, the data arrives from whatever system writes the JSON, and the rendering settings live in one Zapier step. The same five step shape runs on Make, n8n and Power Automate with the same two PDF4me actions.


Common Variations You Can Add Without Rebuilding​

Email the invoice
Add a Gmail or Outlook step after step 5 and attach the File Url from step 4. The customer gets the PDF without anyone opening Dropbox.
Convert a live URL instead
Swap Convert HTML to PDF for Convert URL to PDF and skip steps 2 and 3 when the page already exists on the web.
Stamp or protect the result
Insert Add Watermark or Protect PDF between steps 4 and 5 to brand or password protect the invoice before it is stored.
Automated versus manual conversion
A manual converter needs a person per file and gives no record. This Zap runs unattended, names every output from the source data, and leaves a run history you can audit.

Automated Zap versus a manual converter​

Zap vs manualThis ZapA manual online converter
Who runs itNobody, it fires on file arrivalA person, once per file
NamingTaken from the order data every timeWhatever the browser downloads
Page setupFixed in the Zap, identical on every runRe-chosen by hand each time
RecordA Zap run history you can auditNone
Cost shapeZapier plan plus PDF4me callsFree per file, costly in minutes

Common questions​

How do I convert HTML to PDF?​

Give an HTML file to a renderer and tell it the page setup. In this Zap, PDF4me's Convert HTML to PDF action takes the HTML produced by step 3, applies Portrait layout, A4 paper, scale 0.8 and 40px margins, and returns a PDF. The same action accepts a file you upload directly if you are not merging data first.

Can you convert HTML to PDF for free?​

Converting one file by hand is free in plenty of places, including a browser's own Print to PDF. Automating it is where the cost sits, and it is two separate costs: a paid Zapier plan, because a five step Zap is not a single step Zap, and PDF4me API calls. For a handful of documents a month, manual conversion is genuinely cheaper. The arithmetic changes quickly once the volume is daily.

How do I convert HTML to PDF without losing formatting?​

Three fields do most of the work. Set Print Background to True so CSS background colours and images survive. Lower Scale below 1.0, here 0.8, so a wide table fits inside the content width instead of wrapping. Match Paper Size to the region you print in, A4 or Letter. If a template still breaks across pages badly, add CSS page break rules to the HTML rather than fighting the renderer.

Can I batch convert HTML to PDF?​

Yes, and this Zap already does it one file at a time, continuously, which is usually what people actually want from "batch". Every file dropped into /DocGen/Orders produces its own PDF. For a true batch of many files in one run, use Zapier's Looping action to iterate a list and call Convert HTML to PDF once per item.


Troubleshooting​

The PDF still shows placeholders instead of values

Generate Document did not merge. Check that Input Data Type is Json and that the order file really is valid JSON. A trailing comma is enough to make the merge silently return the untouched template.

The coloured header prints white

Print Background is set to False. Set it to True. This is the single most common formatting complaint with any HTML to PDF renderer, not just PDF4me. The underlying browser behaviour is documented by Mozilla under print-color-adjust.

Step 2 halted: no search results

Find File could not locate invoice-template.html in /DocGen/Templates. Check the spelling and that the file is in that exact folder, not a subfolder, since Include files in subfolders is False.

The Zap triggers itself repeatedly

The output folder sits inside the watched folder, so each saved PDF counts as a new file. Keep /DocGen/Output outside /DocGen/Orders, as in this build.


Next Steps​

The same five step pattern (watch a folder, fetch the template, merge, render, save with a runtime name) handles any "data in, branded document out" automation.