HomeToolsHTML to PDF

Convert HTML to PDF with Custom Layout

Transform HTML files or code into professionally formatted PDFs with pixel-perfect rendering and full layout control. Upload HTML files or paste code directly, then customize page size, margins, scale, headers/footers, and rendering options to create PDFs exactly as you need them.

Key Features

Dual input modes: Upload HTML file or paste HTML code directly
Full CSS3 support - all styles, layouts, and visual elements rendered accurately
JavaScript execution with configurable wait delay for dynamic content
Customizable page settings: Size (A4, Letter, A3), orientation (portrait/landscape), scale (0.1-2.0)
Precise margin control (top, right, bottom, left) in millimeters
Custom header and footer templates with HTML and CSS
Print background graphics option to include background colors and images
Prefer CSS page size option to honor CSS @page rules
Automatic processing: Small files (≤10MB) convert instantly without storage; large files use server processing with 2-hour auto-deletion
Supports files up to 200MB for complex HTML documents

How to Convert HTML to PDF

1

Choose input method: Upload an HTML file (up to 200MB) or check 'Use content instead of file' to paste HTML code directly.

2

Configure page settings: Select page size (A4/Letter/A3), adjust scale (zoom level 0.1-2.0), and set margins in millimeters for each edge.

3

Set rendering options: Enable landscape orientation if needed, turn on 'Print background' to include background colors/images, or enable 'Prefer CSS page size' to use CSS @page rules.

4

Optional: Add custom headers/footers by checking 'Display header/footer' and entering HTML templates. Use placeholders like <span class='pageNumber'></span> for page numbers.

5

Optional: Adjust wait delay (in milliseconds) if your HTML contains JavaScript that needs time to execute before rendering (e.g., for charts or dynamic content).

6

The tool processes based on file size: Files 10MB or smaller convert instantly without server storage. Files over 10MB upload for processing and auto-delete after 2 hours.

7

Click 'Convert to PDF' to start conversion.

8

Download your generated PDF file when ready.

Perfect For

Convert HTML email templates to PDF for testing layouts and previewing before sending campaigns
Generate PDF invoices and receipts from HTML templates with custom headers and footers
Create professional PDF reports from HTML dashboards with charts and dynamic data
Convert HTML documentation to PDF with custom page sizes and margins for printing
Archive HTML content as PDF with precise layout control for long-term storage
Test responsive HTML designs by converting at different scales and page sizes
Convert HTML forms to printable PDFs with custom margins and orientation
Generate PDFs from HTML code snippets for code documentation with syntax highlighting
Create PDF certificates or badges from HTML templates with exact positioning
Convert HTML presentations or slide decks to PDF format for distribution

Why Choose This Tool?

Pixel-perfect rendering - CSS styles, fonts, colors, and layouts render exactly as designed
Full layout control - customize every aspect from page size to margins to scale
JavaScript support - dynamic content like charts, graphs, and animations render correctly
Flexible input - upload files or paste code directly for quick testing and iteration
Professional output - add custom headers/footers with page numbers and branding
Privacy protection: Small files process without storage; large files auto-delete after 2 hours
Works with files up to 200MB for complex HTML documents and templates

Frequently Asked Questions

How do I convert HTML to PDF?
Upload an HTML file or paste HTML code, configure page settings (size, margins, scale), adjust rendering options (landscape, backgrounds, wait delay), optionally add custom headers/footers, then click 'Convert to PDF'. Download when ready.
Can I paste HTML code instead of uploading a file?
Yes! Check the 'Use content instead of file' checkbox to reveal a text area where you can paste HTML code directly. This is perfect for testing snippets or converting code without creating a file.
What page sizes are supported?
A4 (210 × 297 mm), Letter (8.5 × 11 in), and A3 (297 × 420 mm). You can also enable 'Prefer CSS page size' to honor CSS @page rules defined in your HTML.
How do margins work?
Set margins in millimeters for each edge (top, right, bottom, left). Range is 0-100mm. Margins create white space around your content, useful for printing or creating professional layouts.
What does the scale setting do?
Scale controls the zoom level (0.1 to 2.0). 1.0 is normal size, 0.5 makes content half size, 2.0 doubles it. Use scale to fit more content on a page or increase text size for readability.
How do I add headers and footers?
Check 'Display header/footer', then enter HTML templates. Use special classes: <span class='pageNumber'></span> for current page, <span class='totalPages'></span> for total pages. Style with inline CSS (e.g., <div style='font-size:10px;'>My Header</div>).
What is wait delay for?
Wait delay (in milliseconds) pauses before rendering to allow JavaScript to execute. If your HTML loads charts, images, or dynamic content via JavaScript, set a delay (e.g., 1000ms) to ensure everything renders before PDF generation.
Will CSS styles and images render properly?
Yes! The tool supports full CSS3 including layouts, fonts, colors, and images. External stylesheets and images will load. Enable 'Print background' to include background colors and images (disabled by default for printing).
Can I convert HTML with JavaScript?
Yes. JavaScript executes during conversion. Set an appropriate wait delay to give scripts time to run. This works for charts (Chart.js), data tables, and other dynamic content that renders via JavaScript.
What is 'Prefer CSS page size'?
When enabled, CSS @page rules in your HTML override the page size setting. Use this if your HTML defines custom page dimensions via CSS (e.g., @page { size: A4 landscape; }).
What happens to my HTML during conversion?
Small files/content (10MB or less) process on our server but are never stored. Large files (over 10MB) are temporarily stored during processing and automatically deleted after 2 hours.
Is there a file size limit?
Yes, HTML files up to 200MB are supported. This handles large HTML files with embedded images, complex templates, and lengthy documents.

Ready to Get Started?

Fast PDF processing with our powerful online tool. Works entirely in your browser, no installation needed.

Secure Processing
256-bit SSL encryption
Lightning Fast
Process files in seconds
Free to Start
Start with free tier