---
title: "Free HTML to PDF Converter: Paste HTML | ScreenshotAPI.net"
slug: "/tools/html-to-pdf"
description: "Convert HTML to PDF online free. Paste HTML code or upload an .html file, pick A4 or Letter, set landscape, and download a clean PDF in seconds. No signup."
---

# Convert HTML to PDF in Your Browser

To convert HTML to PDF, paste your HTML code or upload an .html file below, choose a paper size such as A4 or Letter, and click Convert to PDF. ScreenshotAPI.net renders the markup in a real browser with your CSS and JavaScript applied, then gives you a PDF to preview and download for free, with no signup.

## How to Convert HTML to PDF in 3 Steps

The whole job takes under a minute, and it works the same for a single line of markup or a full HTML file with its own styles.

2.  1
    
    ### Add your HTML
    
    Paste HTML code into the editor, or switch to the upload tab and drop in an .html or .htm file from your computer.
    
    `custom_html`
3.  2
    
    ### Choose the page setup
    
    Pick A4, Letter, Legal, A3, A5, or Tabloid, turn on landscape for wide tables, and enter a page range if you only need part of the document.
    
    `format · landscape · page_range`
4.  3
    
    ### Convert and download
    
    Click Convert to PDF. The markup is rendered in a real browser, paginated to your paper size, and shown in the preview so you can download it.
    
    `file_type=pdf`

## Paste HTML Code or Upload an HTML File

Both inputs go through the same renderer, so pick whichever matches where your HTML lives right now.

pasted code

1<style>

2h1 { color: #4f46e5; }

3</style>

4<h1>Certificate of Completion</h1>

5<p>Awarded to Jane Doe</p>

### HTML code to PDF

Best for snippets, email templates, and markup your app generates on the fly. Paste anything from a single tag to a full document with a `<head>`. Styles in a `<style>` block or a `style` attribute are applied, and you see a live preview before you convert.

HTMLreport-q3.html48 KB · ready to convert

Drop an .html or .htm file

### HTML file to PDF

Best when you already have a saved page, an exported report, or a template on disk. The file is read in your browser and sent as HTML, so it never needs a public URL. Files up to 1 MB work in the free tool. Larger documents go through the API.

One limit applies to both: a single HTML file cannot carry the folders next to it. Images, fonts, and stylesheets that sit beside the file on your disk will not load, so link them with full `https://` URLs or inline them.

## Page Size, Orientation, and Print Styles

The paper size decides how wide your layout is allowed to be. A4 portrait is narrower than most desktop screens, so a page that looks fine in the browser can wrap differently on paper. Here are the sizes side by side, drawn to scale.

Paper size

A0 to A6, Letter, Legal, Tabloid, and Ledger. Leave it out on the API to get one long page with no breaks.

`pdf_options[format]`

Orientation

Turns the sheet sideways. Use it for wide tables, dashboards, and anything that would otherwise shrink to fit.

`pdf_options[landscape]`

Page range

Keeps only the pages you ask for, such as 2-6. Handy when a long document only needs its summary page.

`pdf_options[page_range]`

Print styles

Applies your @media print rules, so you can hide navigation or buttons that do not belong on paper.

`pdf_options[media]=print`

Backgrounds

Keeps background colours and images. Print mode drops them by default to save ink.

`pdf_options[print_background]`

The free converter covers paper size, landscape, and page range. Print media and backgrounds are available on the API.

## Why Your CSS and Images Look Right in the PDF

A PDF is only as good as the engine that lays out the HTML. ScreenshotAPI.net renders it in a browser first, which is why the PDF matches the preview. Four things are worth knowing.

CSSYour styles are applied, not stripped

The HTML is loaded in a real browser engine, so a <style> block, inline style attributes, flexbox, grid, and web fonts from a stylesheet link all render the way they do on screen.

JavaScriptScripts run before the PDF is built

Inline JavaScript executes during rendering, so charts and content you inject with a script make it onto the page. If a chart animates in, add a short delay on the API so it finishes first.

ImagesRelative paths have nothing to point at

This is the most common reason images or fonts go missing. Pasted HTML has no folder or domain behind it, so a path like images/logo.png cannot be found. Use a full URL, or embed small images as data URIs.

Breaks`<img src="images/logo.png">`

Works`<img src="https://example.com/logo.png">`

## HTML to PDF vs Saving a Webpage as PDF

Both end in a PDF, but they start from different places. If you want to save HTML as PDF and the HTML is in your hands, use this page. If it lives at a web address, use the webpage converter.

vs

You are here

### HTML to PDF Converter

You start with

HTML code or an .html file

Content comes from

Exactly the markup you give it

Works for private pages

Yes, nothing has to be online

Typical job

Invoices, receipts, certificates, templates

[Convert HTML now](https://www.screenshotapi.net/tools/html-to-pdf#playground)

Different input

### Webpage to PDF Converter

You start with

A link to a live, public page

Content comes from

Whatever the site serves when it loads

Works for private pages

Only if the page is publicly reachable

Typical job

Articles, docs, receipts from a site, archives

[Save a webpage as PDF](https://www.screenshotapi.net/tools/url-to-pdf-generator)

## What People Build With HTML to PDF

Any document that starts life as a template is a good fit. Write it once in HTML and CSS, then turn every copy into a PDF.

### Invoices

Keep one HTML invoice template, fill in the numbers, and turn each one into an A4 or Letter PDF that is ready to email.

### Reports

Export a monthly report built with HTML tables and charts as a PDF that clients can file and print without a login.

### Certificates

Design a certificate once in HTML and CSS, switch to landscape, and produce a personalised PDF for every attendee.

### Tickets and passes

Render event tickets and boarding passes with a QR code image from a URL, sized to fit a single printed page.

### Receipts

Turn the HTML receipt your checkout already sends by email into a PDF copy customers can download later.

### Contracts and quotes

Generate quotes and agreements from HTML templates on Legal or Letter paper, keeping fonts and spacing consistent.

## Automate HTML to PDF With the ScreenshotAPI.net API

Generating invoices or certificates from your app? Send the same HTML in a POST request and get the PDF back in one call, from cURL, JavaScript, Python, or any language that speaks HTTP.

`custom_html`

Your HTML as a string. It overrides url, and inline CSS and JavaScript are applied.

`pdf_options.format`

A0 to A6, Letter, Legal, Tabloid, or Ledger.

`pdf_options.landscape`

true for wide layouts, false for portrait.

`pdf_options.page_range`

Keep only some pages, for example 1-3.

## Free HTML to PDF Converter vs Other Online Tools

The best HTML to PDF converter depends on what you start with. Here is how this tool compares with two popular free pages, including the places where they do more.

| Feature | ScreenshotAPI.net | Pdfcrowd | Smallpdf |
| --- | --- | --- | --- |
| Paste HTML code | Yes | Yes | No  |
| Upload an .html file | Yes | Yes | Yes |
| Convert from a URL | Separate tool | Yes | No  |
| Paper size and landscape | Yes | Paid license | No  |
| Custom margins, footers, and page numbers | No  | Paid license | No  |
| Upload a zip with images and CSS | No  | Yes | No  |

Based on each tool's public HTML to PDF page, checked October 2026. Pdfcrowd's inputs are free, but its settings panel, which holds page size, orientation, margins, and footer page numbers, is locked until you buy a license, and free output carries Pdfcrowd branding. For a URL, ScreenshotAPI.net has a separate [webpage to PDF converter](https://www.screenshotapi.net/tools/url-to-pdf-generator).

## HTML to PDF FAQ

Common questions about converting HTML code and HTML files to PDF, missing images, and automating it with the ScreenshotAPI.net API.

Don't see your question here?

[Browse all help articles](https://www.screenshotapi.net/help)
