Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To convert an .htm file to PDF, open it in a browser and choose the browser’s Print or Save to PDF destination. That renders the HTML instead of merely renaming the file. For repeatable jobs, use a renderer such as wkhtmltopdf or browser automation with Playwright’s page.pdf(). After conversion, inspect images, fonts, page breaks, headers, and links because local assets and print CSS can change the result.
What HTM-to-PDF conversion actually does
.htm is an HTML document extension; .html is the more common equivalent. A PDF conversion lays out that document on pages and writes a PDF file. Renaming report.htm to report.pdf does not convert anything and will produce a file PDF readers cannot interpret.
The renderer must load the document, resolve its CSS and images, run any required JavaScript, apply print rules, and then create fixed pages. A local file may depend on adjacent folders such as images/, css/, or fonts/. Keep those paths intact while converting.
Fastest method for one HTM file: print from a browser
- Put the HTM file and its referenced assets in their expected relative locations.
- Open the file in your browser, either by double-clicking it or using the browser’s Open File command.
- Open the browser’s Print command.
- Choose the system or browser destination that saves as PDF, select paper size and orientation, and decide whether backgrounds should print.
- Save the PDF, then open it in a PDF viewer and check every page.
Browser labels and menu locations vary by browser and operating system, so use the current Print dialog shown by your installation rather than relying on a universal shortcut. The workflow is suitable for a single document, but it is manual and difficult to reproduce exactly across many files.
#1 Best Overall
- Transform audio playing via your speakers and headphones
- Improve sound quality by adjusting it with effects
- Take control over the sound playing through audio hardware
What to check before closing the print dialog
- Layout: switch between portrait and landscape when wide tables or code blocks are clipped.
- Margins: reduce them only when content is being cut off; very small margins can collide with printer-style headers and footers.
- Backgrounds: enable background graphics if the design depends on colored panels or images.
- Scale: use a smaller scale for oversized content, then verify that text remains readable.
- Page breaks: look for headings stranded at the bottom of a page and tables split in unusable places.
- Assets: missing images or fonts usually indicate a broken relative path, blocked local access, or a resource that was never downloaded.
Command-line conversion with wkhtmltopdf
wkhtmltopdf is an open-source, headless command-line utility that renders a URL or file to PDF using Qt WebKit. Its documented options cover JavaScript behavior, print media, loading errors, and local-file access. Builds and packages differ, so verify the options supported by the version installed on your system; the widely referenced manual describes version 0.12.6 with patched Qt.
Basic commands
wkhtmltopdf report.htm report.pdf
wkhtmltopdf file:///absolute/path/report.htm report.pdf
Use an absolute file:// URL when a relative path is not resolving as expected. Run the command from a directory that contains the document and its asset folders, or provide absolute paths in the HTML.
Useful rendering controls
wkhtmltopdf
--print-media-type
--enable-javascript
--javascript-delay 1000
--enable-local-file-access
report.htm report.pdf
--print-media-type asks the renderer to use print CSS. JavaScript is normally relevant when the page builds content after load; a delay gives that code time to finish. Local-file access is important when the HTM references nearby images, stylesheets, or fonts. Grant only the access needed for the document and confirm the exact flag names with wkhtmltopdf --extended-help, because downstream builds may change defaults or availability.
Handling failures instead of hiding them
Do not automatically suppress load errors while troubleshooting. A PDF can be created even when an image, stylesheet, or script failed. First run the command with its normal diagnostics, fix missing resources, and only then decide how your batch process should treat non-fatal loading errors.
Rank #2
- Mix an audio, music and voice tracks
- Record single or multiple tracks simultaneously
- Intuitive tools to split, trim, join, and many other editing features
- Loaded with audio effects including EQ, compression, reverb, and more.
- Load an audio file and export to all popular audio formats from studio quality wav to high compression formats
Automated conversion with Playwright
Playwright controls a real browser engine and exposes page.pdf(). The API generates PDF output with print CSS by default and provides controls for paper format, margins, backgrounds, page ranges, and CSS page-size preference. API details are version-sensitive, so consult the documentation matching your installed Playwright version.
Install and run a Node.js converter
npm install playwright
npx playwright install chromium
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage({
viewport: { width: 1280, height: 900 },
deviceScaleFactor: 1
});
await page.goto('file:///absolute/path/report.htm', {
waitUntil: 'networkidle'
});
await page.pdf({
path: 'report.pdf',
format: 'A4',
printBackground: true,
margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' },
preferCSSPageSize: true
});
await browser.close();
Replace the file URL with an HTTPS URL when converting a hosted page. For pages that never become idle because of analytics or polling, use a targeted wait instead, such as await page.waitForSelector('#content'), followed by a short controlled delay. For a long document, test a representative sample before processing a large batch.
Why print CSS matters
Web layouts often have a separate @media print stylesheet. It may hide navigation, change colors, or insert page-break rules. Playwright’s PDF method uses that print media context by default; if your design expects screen styling, explicitly set the page’s media mode before generating the PDF and verify the result.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choosing the right workflow
| Situation | Best starting point | Important trade-off |
|---|---|---|
| One local file | Browser Print/Save to PDF | Fastest setup, but manual and less reproducible |
| Shell script or scheduled job | wkhtmltopdf | Simple automation; JavaScript and modern CSS behavior depends on the installed Qt WebKit build |
| JavaScript-heavy pages or precise browser control | Playwright page.pdf() |
More setup and browser binaries, but explicit waits and PDF options |
| Many URLs or an API pipeline | Hosted screenshot/PDF API | Less local browser maintenance; review billing, resource handling, and failure reporting |
Compare any two approaches on print-CSS fidelity, JavaScript execution, local and remote resource access, paper and margin controls, page ranges, repeatability, and operational cost. Those differences matter more than the file extension.
Rank #3
- Intuitive interface of a conventional FTP client
- Easy and Reliable FTP Site Maintenance.
- FTP Automation and Synchronization
Local files, images, stylesheets, and security
Relative URLs are resolved from the document’s location. If report.htm contains <img src="images/chart.png">, keep images/chart.png at that relative path or rewrite the reference. A CSS file can itself reference fonts and background images, so check nested paths too.
Remote resources may fail because of authentication, certificate errors, a blocked network, or a script that requires a user gesture. Local-file controls in command-line renderers determine whether adjacent files can be read. Give a renderer access only to the directory it needs, especially when converting untrusted HTML, and do not treat a successful PDF as proof that every external request was safe.
Quality checklist after conversion
- Open the PDF and confirm the expected page count.
- Zoom into text, diagrams, and small table cells.
- Check the first and last page for clipped content.
- Compare images with the source for missing, stretched, or low-resolution assets.
- Check links if the PDF must remain navigable.
- Search for text to detect a PDF that is only a flattened image when selectable text was required.
- Review confidential data in remote URLs, cookies, and generated files before distributing the PDF.
Common errors and fixes
The output is blank
Check that the input path is correct and that the document has visible content without JavaScript. For dynamic pages, enable JavaScript and wait for a known selector or a controlled delay. A blank page can also result from a script error or a page that requires authentication.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Images or CSS are missing
Preserve the asset directory structure, use correct case-sensitive filenames, and test absolute paths. For a local conversion, review the renderer’s local-file-access setting. For remote assets, verify that the conversion environment can reach the URLs without a login.
Rank #4
Content is cut off or overlaps
Change paper format, orientation, scale, or margins. Inspect print CSS for fixed-width elements, absolute positioning, and missing page-break rules. Wide tables often need landscape pages or a print-specific layout.
JavaScript content is absent
Wait for the application’s completion signal rather than immediately printing. In Playwright, wait for a selector that appears only after rendering. In wkhtmltopdf, confirm JavaScript is enabled and choose a delay appropriate to the page; a fixed delay is less reliable than a deterministic readiness condition.
Fonts differ from the browser preview
Ensure the font files are available and permitted to load, and allow the page to finish loading before capture. A fallback font can change line wrapping and therefore every page break.
Recommended Free Tools
The command works locally but fails in a job runner
Use absolute paths, install the required browser or renderer in the runner image, and log the exact version. Check sandbox, network, certificate, and file-permission differences between your workstation and the automated environment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo provides a GET-based screenshot and PDF API for hosted pages, so you do not have to maintain a local browser. It accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response reports the page verdict and billing status in headers.
For a publicly reachable HTML page, call the API like this (replace the URL with your page):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the complete parameter list and PDF options in the ScreenshotNeo documentation. The service also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients; full-page capture, element selection, device presets, custom CSS and JavaScript, waits, request blocking, cookies, headers, geolocation, caching, signed links, async webhooks, bulk capture, and usage reporting are available across plans.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free. Create a free ScreenshotNeo account to try it.
FAQ
Is HTM the same as HTML?
They are filename extensions for HTML documents. The extension itself does not determine PDF quality; the renderer and the document’s resources do.
Can I convert an HTM file without an internet connection?
Yes, if the document and all required local assets are available and the renderer does not depend on remote fonts, images, scripts, or authenticated services.
Will links remain clickable in the PDF?
Often, but behavior depends on the renderer and the HTML. Verify links in the generated file when navigation is a requirement.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

