How to Convert HTML to PDF on Windows
Convert any web page or local HTML file to PDF on Windows with Edge, Acrobat, WebView2, or a single ScreenshotNeo API call.
Fastest answer: Open the web page or local .html file in Microsoft Edge, press Ctrl+P, choose Save as PDF, adjust paper size, scale, headers, footers, and background graphics, then save. For automation, use WebView2’s PrintToPdf; for multi-page or whole-site capture, use Acrobat; or use ScreenshotNeo when you want an API request that returns a PDF.
1. Convert HTML to PDF with Microsoft Edge
Edge is the simplest free option for a single page, receipt, article, documentation page, or local HTML file. Microsoft documents the print workflow and its layout controls in its Edge printing guidance.
Step-by-step
- Open the URL in Edge. For a local file, press Ctrl+O and select the
.htmlfile, or enter itsfile:///path. - Press Ctrl+P, or open the three-dot menu and choose Print.
- Set the printer or destination to Save as PDF (the wording can vary by Windows version).
- Check the preview before saving. It reveals clipped columns, unexpected page breaks, missing colors, and blank pages.
- Choose a paper size such as Letter or A4 and set orientation to Portrait or Landscape.
- Use Fit to printable area when content is cut off. Use Actual size when preserving the source scale matters more than fitting the page.
- Turn on Background graphics when colors, shaded sections, or background images are missing.
- Turn on Headers and footers only when the title, URL, date, or page number is useful.
- Click Save, choose a filename and folder, then reopen the PDF and inspect page breaks and links.
What Edge preserves
Edge prints the rendered page, including the current responsive layout. It does not automatically create a multi-level crawl of a website. JavaScript must finish rendering before you print, and content hidden behind a click or an uncompleted login flow may not appear.
2. Convert a local HTML file correctly
Keep relative assets beside the HTML file so the browser can resolve them:
project/
report.html
css/
print.css
images/
chart.png
fonts/
report.woff2
Open report.html in Edge, wait for images and fonts to load, then use the print workflow. If the page has a print stylesheet, add rules such as:
@media print {
@page { size: A4; margin: 16mm; }
nav, .no-print { display: none !important; }
a { color: inherit; text-decoration: none; }
.page-break { break-before: page; }
}
For pages that load data from a local server, start that server first and print the http://localhost URL. A file:// page can behave differently because browser security rules may block network requests.
3. Use Adobe Acrobat for advanced capture
Acrobat can convert an open page through its browser extension. Acrobat desktop also accepts a URL or local HTML file and can capture multiple levels or an entire site. Adobe’s web-page conversion documentation covers the browser workflow; its desktop settings include page size, orientation, scaling, encoding, image conversion, bookmarks, PDF tags, headers, and footers.
Acrobat workflow
- Open the HTML page or choose the local HTML file in Acrobat’s web-page conversion tool.
- Choose one page, multiple levels, or the entire site.
- When crawling, restrict capture to the same path or same server if you do not want external links included.
- Set page size, orientation, margins, scaling, encoding, image conversion, headers, and footers.
- Enable bookmarks or PDF tags when the document needs navigation or accessibility structure.
- Start the conversion and review the resulting PDF for missing assets and unexpected crawl boundaries.
4. Automate HTML-to-PDF conversion in a Windows app with WebView2
Microsoft WebView2 exposes PrintToPdf for silently printing the current top-level document to a PDF file. The API is useful when a Windows application must produce repeatable files without opening the print dialog. See the WebView2 printing documentation for the current API details.
C# example
using Microsoft.Web.WebView2.Core;
using System;
using System.IO;
using System.Threading.Tasks;
public static class HtmlPdf
{
public static async Task SaveAsync(CoreWebView2 webView, string outputPath)
{
if (webView == null) throw new ArgumentNullException(nameof(webView));
if (string.IsNullOrWhiteSpace(outputPath)) throw new ArgumentException("Output path is required.", nameof(outputPath));
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(outputPath))!);
var settings = new CoreWebView2PrintSettings
{
ShouldPrintBackgrounds = true,
ShouldPrintHeaderAndFooter = false,
PageWidth = 8.27,
PageHeight = 11.69,
ScaleFactor = 1.0
};
await webView.PrintToPdfAsync(outputPath, settings);
}
}
Navigate the WebView2 control first, wait for the page’s data and images to finish loading, then call SaveAsync. Handle navigation failures and choose an output path your process can write.
5. Or skip the browser setup
ScreenshotNeo provides a website screenshot and PDF API. One GET request can render a URL and return a PDF. The API accepts options for paper size, margins, landscape mode, page ranges, waiting for a selector or network idle, custom headers and cookies, JavaScript, custom CSS, blocking resources, and more. See the ScreenshotNeo API documentation for parameter names and response details.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-d format=pdf \
-o page.pdf
Python
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={
"access_key": "YOUR_API_KEY",
"url": "https://stripe.com",
"format": "pdf",
},
timeout=90,
)
r.raise_for_status()
open("page.pdf", "wb").write(r.content)
Node.js
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://stripe.com',
format: 'pdf'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('page.pdf', data);
Cookie banners, newsletter popups, and chat widgets are removed before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. One thousand screenshots per month are free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
6. PDF options that affect the result
| Need | Edge | Acrobat | WebView2 / API |
|---|---|---|---|
| One visible page | Excellent | Good | Good |
| Local HTML file | Yes | Yes | Load through your app |
| Whole site or multiple levels | No | Yes | Implement URL collection or use an API workflow |
| Silent automation | No | Limited | Yes |
| Bookmarks and PDF tags | Basic browser output | Advanced settings | Application-controlled |
| Background colors and images | Enable Background graphics | Conversion settings | Print settings or API option |
7. Troubleshooting
The PDF cuts off the right side
Use Fit to printable area, switch to Landscape, choose a larger paper size, or reduce the scale. Check the preview after each change.
Colors or background images are missing
Enable Background graphics in Edge. In an automated workflow, enable the equivalent background-print setting.
Headers and URLs make the page look cluttered
Disable Headers and footers. Enable them only when title, URL, date, or page numbers serve a purpose.
Images, fonts, or CSS are missing from a local file
Verify relative paths, keep assets available beside the HTML file, and inspect the page in Edge before printing. If the page needs API data, serve it from localhost instead of opening it directly with file://.
The PDF contains a blank page
Look for print CSS with oversized fixed-height elements, forced page breaks, or an empty trailing container. Remove unnecessary break-after rules and preview again.
JavaScript content is absent
Wait until the page finishes loading and data appears before printing. For automation, wait for a specific selector or application-ready event rather than relying only on navigation completion.
A long website is incomplete
Edge prints the current page. Use Acrobat’s multi-level or entire-site capture and configure same-path or same-server limits, or collect the URLs explicitly in your automation.
WebView2 cannot write the PDF
Check that the destination directory exists and that the process has write permission. Also handle navigation errors before calling PrintToPdfAsync.
An API response is not a PDF
Check the HTTP status and response headers before saving bytes. A failed page, bot check, timeout, or blank result should be handled according to the API response metadata instead of being treated as a valid document.
8. Performance, reliability, and cost
- Preview first: Edge is efficient for a one-off conversion because it needs no setup.
- Reduce rework: Set print CSS, paper size, scale, and background behavior before generating batches.
- Wait for real readiness: Data-heavy pages need a selector, delay, or network-idle condition so the PDF does not capture an intermediate state.
- Keep inputs stable: Pin local assets and avoid expiring authenticated URLs when producing repeatable files.
- Choose the workflow by scope: Acrobat handles site depth; WebView2 handles application automation; an API handles server-side jobs without managing a browser.
- Budget for failures: ScreenshotNeo bills only clean shots; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Its response includes
X-Page-VerdictandX-Billedheaders.
9. FAQ
Can I convert HTML to PDF without installing software?
Yes. Edge is included with Windows and can save the current page through its print dialog. A hosted API such as ScreenshotNeo can also perform the render remotely.
Does printing HTML create a searchable PDF?
Browser-generated PDFs normally preserve selectable text when the source text is rendered as text. Text drawn into a canvas or an image may not be searchable.
Should I use A4 or Letter?
Use the paper size expected by the people or systems receiving the document. Change the layout to match that size before saving.
How do I convert many URLs?
Use an automated workflow. Acrobat supports multi-level and whole-site capture; WebView2 can be integrated into a Windows app; ScreenshotNeo supports asynchronous jobs, signed webhooks, and bulk capture of up to 100 URLs per call.
Can I preserve a dark-mode page?
Set the page’s theme before capture. ScreenshotNeo supports dark mode as an option, while browser printing follows the rendered page and its print styles.


