BasicApps Logo
Try HTML to PDF Tool Now - Free

No account needed · Works in browser · Free

PDF Tools12 min readBy Jamie Mercer · document workflow specialist

Convert HTML to PDF: Complete Guide with Advanced Settings

My accountant asked me to submit a bank statement page that only existed online with no download link — I saved the HTML locally, ran it through this tool, and had a clean PDF to attach in about four minutes. Whether you're archiving a live page, generating a report, or saving something with no export button, a browser-based converter handles it without anything to install. Once you have the PDF you can password-protect it or merge it with other documents.

HTML to PDF tool with URL input showing a live web address
Paste any public URL — the tool loads and renders the page exactly as a browser would.

Everything runs client-side. Nothing is uploaded to a server, so there's no queue and no account needed. Page size, orientation, margins, and device viewport are all adjustable before you convert.

Three Ways to Convert HTML to PDF

The tool accepts HTML three ways — live URLs, uploaded files, and pasted code. All three produce equivalent PDF output; the choice depends on where your HTML lives.

1. Convert URLs to PDF

Paste any website URL and the tool fetches the complete page with all styles, images, and fonts. This method works great for saving articles, reports, or any public web page as a PDF document.

  • Enter multiple URLs (one per line) to convert several pages at once
  • Captures live content including JavaScript-rendered elements
  • Downloads all linked resources like CSS files and images
  • Perfect for archiving web content or creating offline copies
  • Handles responsive designs and modern CSS features

2. Upload HTML Files

Drag and drop HTML or HTM files from your computer. The converter processes local files and resolves relative paths to stylesheets and images within the same directory.

  • Supports .html and .htm file extensions
  • Maintains file structure and linked resources
  • Ideal for converting saved web pages or email archives
  • Works with templates and local HTML projects
  • Preserves embedded styles and inline CSS

3. Write HTML Code Directly

Use the built-in code editor to write or paste HTML and CSS directly. This method gives you complete control over the document structure and styling.

  • Live character count to track document size
  • Syntax validation ensures proper HTML structure
  • Perfect for creating custom documents from scratch
  • Supports inline CSS and external stylesheet references
  • Real-time preview of your HTML content

Advanced PDF Settings and Options

The converter provides professional PDF output options to match your specific needs. Configure every aspect of the PDF generation process.

HTML to PDF code editor mode with sample HTML entered
Paste raw HTML directly into the editor for precise, offline document generation.

Page Size Options

Choose from standard paper sizes or create custom dimensions for your PDF output:

  • A4: 210 x 297mm - Standard international paper size
  • Letter: 8.5 x 11 inches - Standard US paper size
  • Legal: 8.5 x 14 inches - Extended US legal documents
  • One Long Page: Captures entire content without page breaks

The "One Long Page" option is useful for dashboards and long-scrolling articles where you want one unbroken render rather than content chopped across pages.

Layout and Formatting Controls

Fine-tune how your HTML content appears in the final PDF document:

  • Orientation: Portrait or landscape layout options
  • Margins: Standard, minimum, or no margins around content
  • Device View: Desktop (1440px), tablet (768px), or mobile (375px) rendering

The device view setting determines how responsive websites appear in your PDF. Choose desktop for full-width layouts or mobile for narrow, single-column designs that work better in printed documents.

CSS Rendering Capabilities

The converter uses the WeasyPrint engine to handle modern CSS features that other HTML-to-PDF tools often struggle with. This ensures pixel-perfect conversion of complex layouts.

Supported CSS Features

  • Flexbox Layout: Complete flex container and item properties
  • CSS Grid: Grid templates, areas, gaps, and spanning
  • Custom Properties: CSS variables with fallback values
  • Web Fonts: @font-face declarations, Google Fonts, WOFF2 files
  • Print Styles: @page rules for page size and margins
  • Media Queries: @media print for print-specific styling
  • Visual Effects: Gradients, box shadows, and transforms

Page Break Control

Use CSS page break properties to control how content flows across PDF pages:

  • break-before: page - Start element on new page
  • break-after: page - Force page break after element
  • break-inside: avoid - Keep element together on one page

How the URL, File, and Code Modes Differ

URL mode fetches a live page and executes JavaScript, so single-page apps and dashboards render fully. File mode reads a saved .html file from your computer; relative paths to local assets resolve if everything is in the same folder. Code mode is for pasting markup directly — fastest for quick tests or programmatically-generated HTML.

In all three modes you configure page size, margins, orientation, and viewport width before converting. The PDF downloads as soon as rendering finishes — no queuing step.

HTML to PDF settings panel: A4 landscape with tablet device view selected
A4 landscape + tablet viewport — ideal for wide dashboard or analytics pages.

Common Use Cases and Applications

Fine-tune before sharing

Trim unwanted margins or whitespace from your HTML-generated PDF pages with the crop tool.

Crop PDF pages →

A few common situations where this actually gets used:

Business and Professional

  • Generate invoices and receipts with custom branding
  • Create reports from web dashboards and analytics tools
  • Convert contract templates for client signatures
  • Archive important web pages for legal documentation
  • Create marketing materials from HTML email templates

Personal and Educational

  • Save online articles for offline reading
  • Convert resume templates to PDF format
  • Create study materials from educational websites
  • Archive email newsletters and important communications
  • Generate portfolios from HTML showcases

Development and Testing

  • Test print stylesheets and page layouts
  • Generate documentation from HTML templates
  • Create PDF previews of web applications
  • Convert HTML emails to shareable PDF format
  • Archive website versions for compliance

Tips for Better PDF Output

Follow these best practices to ensure your HTML converts to high-quality PDF documents.

CSS Optimization

  • Use @media print rules to hide navigation and ads
  • Define page margins with @page CSS rules
  • Specify print-friendly fonts that render well in PDF
  • Use relative units (em, rem, %) instead of fixed pixels
  • Test with different page sizes to ensure content fits properly

Content Structure

  • Include complete HTML structure with head and body tags
  • Use semantic HTML elements for better document structure
  • Keep line lengths reasonable for PDF page widths
  • Avoid fixed positioning that might break in PDF

Image and Resource Handling

  • Use absolute URLs for images in URL conversion mode
  • Ensure images have proper alt text for accessibility
  • Optimize image sizes to reduce PDF file size
  • Include all CSS files inline or via absolute URLs
  • Test with different image formats for best results

Technical Limitations and Considerations

Professional PDF needs page numbers?

Stamp page numbers onto your converted PDF in any position and style in seconds.

Add page numbers

A few things worth knowing before you start:

JavaScript Handling

URL mode fetches and renders JavaScript-generated content, making it compatible with modern web applications. File mode and code mode process static HTML only.

For single-page applications (SPAs), use URL mode to capture the fully rendered content after JavaScript execution.

Performance Factors

Conversion speed depends on content complexity, external resources, and page size. Simple HTML documents convert in seconds, while complex pages with many images may take longer.

A page with many high-resolution screenshots takes longer than a text-heavy document. Downsizing images first saves time if you're converting something image-heavy.

File Size Considerations

PDF file size increases with embedded images, custom fonts, and complex layouts. Use compressed images and standard fonts to keep file sizes manageable.

Frequently Asked Questions

How do I convert HTML to PDF without losing formatting?

Use our WeasyPrint-powered converter that preserves all CSS3 styling including fonts, colors, layouts, and modern features like Flexbox and CSS Grid. The output PDF maintains pixel-perfect formatting exactly as displayed in browsers. Include all CSS inline or via absolute URLs for best results.

Can I convert password-protected websites to PDF?

URL mode only works on publicly accessible pages. Login-required or intranet pages cannot be converted - save the HTML locally and use file upload mode instead.

What's the difference between the three input modes?

URL mode fetches the live page including JavaScript-rendered content, useful when the final visual state matters. File mode processes a saved HTML file with its relative assets. Code mode takes raw HTML or CSS you paste directly, which is fastest for programmatically generated markup. The choice is almost always determined by where your content lives, not by output quality, since all three modes produce equivalent PDF output for the same content.

How large can my HTML file be for conversion?

There's no strict file size limit, but very large HTML documents or pages with many high-resolution images may take longer to process. For best performance, optimize images and remove unnecessary code before conversion.

Does the converter support responsive design in PDFs?

Yes, use the device view setting to control how responsive websites appear in your PDF. Choose desktop view for full-width layouts, tablet for medium screens, or mobile view for narrow single-column designs that work well in printed documents.

Can I convert multiple HTML pages at once?

Yes, in URL mode you can enter multiple URLs (one per line) to convert several pages in a batch. Each URL will be processed as a separate PDF document that you can download individually.

Want to annotate your PDF after converting?

Use our PDF editor to add text, highlights, signatures, and shapes to any page of the converted document.

Edit PDF

Related Articles