Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate a PDF from HTML online, use a hosted converter when you want to avoid installing software. If you need to control rendering or automate the process, use Puppeteer to print a web page to PDF; for command-line scripts, wkhtmltopdf is another option. The right choice depends on whether you are converting a URL or local HTML, how much JavaScript the page needs, and how closely the PDF must match your print styles.

Choose an HTML-to-PDF method

Method Best for Trade-off
Hosted online converter or API Occasional conversions or an application that should not manage a browser. Check the provider’s privacy, retention, upload limits, JavaScript support, CSS fidelity, and pricing before sending content.
Puppeteer Programmatic conversion of pages that rely on modern JavaScript, or repeatable browser-based output. Requires a Node.js environment and a managed browser process.
wkhtmltopdf Scripts and batch jobs that can use a headless command-line renderer. Uses an older Qt WebKit rendering model, which may not match modern browsers.

A hosted tool is the most direct no-install route: submit HTML or a URL, configure the available PDF options, then download the result. No particular hosted converter is recommended here; compare its data-handling and rendering terms before choosing one.

Generate a PDF from a URL with Puppeteer

Puppeteer’s Page.pdf() creates PDF bytes from a rendered page and can save them to a file. Its documented example navigates to a URL and saves hn.pdf. The PDF method uses print CSS by default, so a page may look different from its screen presentation.

Install and run

  1. In a Node.js project, install Puppeteer with npm install puppeteer. Puppeteer installs a compatible browser for its standard setup.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Save the following as html-to-pdf.js:

    const puppeteer = require('puppeteer');
    
    (async () => {
      const browser = await puppeteer.launch();
      try {
        const page = await browser.newPage();
        await page.goto('https://example.com', { waitUntil: 'networkidle2' });
        await page.pdf({ path: 'output.pdf', format: 'A4' });
      } finally {
        await browser.close();
      }
    })();
  3. Run node html-to-pdf.js. The output file is output.pdf in the current directory.

Replace the example URL with the page you are permitted to access. The official guide’s networkidle2 navigation option waits for the page to become quiet before printing, but pages with ongoing network activity may not reach that condition promptly. For pages whose content is populated asynchronously, use an explicit readiness condition suited to that page before calling page.pdf().

Set paper, margins, and output

page.pdf() accepts options for paper format, margins, output path, header and footer templates, and tagged PDF support. For example, change the PDF call to:

await page.pdf({
  path: 'output.pdf',
  format: 'A4',
  printBackground: true,
  margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' }
});

Use an explicitly named format such as A4 or select a custom paper size when your output requires it. Header and footer templates can add print-time details such as page numbers; consult the Puppeteer API for the accepted template markup and option details. Tagged PDF support is available as an option, but whether it meets a particular accessibility requirement should be verified in the resulting document.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the PDF match the intended design

Choose print or screen styles

By default, Puppeteer prints using the print CSS media type. This means @media print rules apply, and screen-only layouts may disappear or change. To render screen styles instead, set the media type before generating the PDF:

await page.emulateMediaType('screen');
await page.pdf({ path: 'output.pdf', printBackground: true });

For a print-oriented document, keep the default and inspect the page’s @media print rules. For a PDF intended to preserve the on-screen layout, emulate screen and compare the output with the page in a browser.

Check colors, page breaks, and assets

Convert HTML from the command line with wkhtmltopdf

wkhtmltopdf is a headless, open-source command-line renderer for converting HTML to PDF; the project also describes wkhtmltoimage for image output. Its rendering engine is Qt WebKit, so test modern layouts and JavaScript-dependent pages rather than assuming browser parity.

Convert a URL

wkhtmltopdf https://example.com output.pdf

Convert a local HTML file

wkhtmltopdf ./index.html ./output.pdf

For local assets, use paths the renderer can access and verify that images, stylesheets, and fonts load from the file or its referenced locations. The project documents options for page size, margins, and related output controls; use its command’s help or documentation for the exact flags supported by the installed build.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate a PDF from HTML with ScreenshotNeo

If your source is a publicly reachable web page and you want a hosted request rather than browser setup, ScreenshotNeo can return a PDF from one GET request. It is a website screenshot API and MCP server from Yorker Media. Its PDF options include paper size, margins, landscape orientation, and page ranges. It is not a general-purpose upload endpoint for arbitrary local HTML files: provide a URL the service can reach.

Or skip the browser setup

Use the documented API endpoint and set the output format to PDF:

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -d format=pdf 
  -o page.pdf

See the ScreenshotNeo API documentation for authentication and PDF parameters. A hosted capture is useful when the work would otherwise involve setting up a browser. ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.

The Free plan includes 1,000 shots per month with no card required. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free. Every feature is on every plan. For the full options, visit ScreenshotNeo. Sign up free for 1,000 screenshots a month with no card.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common PDF problems

The PDF is blank or missing page content

  • Likely cause: The page had not rendered its content before printing, or navigation did not complete as expected.

  • Fix: Wait for the relevant selector or application-ready signal before calling page.pdf(). For a hosted service, check its response verdict and billing headers to distinguish a blank-page result from a successful capture.

The page looks different from the browser

Images or fonts are missing

The conversion hangs or times out

The output has clipped content or awkward page splits

  • Likely cause: Paper size, margins, or print CSS do not suit the content.

  • Fix: Adjust the PDF format and margins, then inspect page breaks around large elements and tables. Add print-specific break rules where appropriate.

Privacy, reliability, and cost considerations

A local Puppeteer or wkhtmltopdf workflow keeps conversion under your own environment’s control, but you are responsible for browser installation, execution, and output handling. A hosted converter removes that setup burden but receives the submitted URL or content; before using one for confidential material, check what it stores, how long it retains it, and where processing occurs. Also verify JavaScript support and pricing for the specific provider. For automated use, account for page readiness, unavailable resources, access controls, and transient failures; a successful HTTP request alone does not guarantee a complete document.

For ScreenshotNeo, only clean shots are billed, while its response identifies page verdict and billing state. For other hosted providers, do not assume equivalent billing treatment: read their current terms. A local CLI can be suitable for batch jobs, but an older rendering engine may require changes to the HTML or CSS to achieve the intended result.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I convert a webpage to PDF without installing software?

Yes. Use a hosted HTML-to-PDF converter or API, but check its privacy, retention, limits, JavaScript support, CSS fidelity, and pricing before submitting the page.

Does Puppeteer make PDFs with screen or print styling?

Print styling by default. Call page.emulateMediaType('screen') before page.pdf() when you need screen media styles.

Can wkhtmltopdf convert a URL as well as a file?

Yes. Its command accepts a URL or local HTML input; verify that the renderer can access any referenced assets.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.