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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

For a Bootstrap page that relies on JavaScript, web fonts, or modern CSS, render it in Chromium with Puppeteer or Playwright, then save the page as a PDF. For static HTML and CSS, WeasyPrint is a useful Python or command-line alternative. The key detail is that browser PDF generation uses print styles by default: Bootstrap may need explicit print rules, reachable assets, and time to finish loading before capture.

Choose a renderer that fits your Bootstrap page

Renderer Best fit Important trade-off
Puppeteer or Playwright JavaScript-driven pages, modern CSS, and output that should closely match Chromium rendering. Requires a browser runtime. PDF generation uses print media by default; configure print styles or explicitly emulate screen media.
WeasyPrint Mostly static HTML/CSS rendered from Python or a command-line pipeline, with document-oriented page controls. It is not a browser runtime for executing an application. Its use with untrusted HTML or CSS requires security controls.
wkhtmltopdf Existing workflows built around its command-line interface or legacy templates. It uses the older Qt WebKit engine, so validate modern Bootstrap layout, flexbox, fonts, and JavaScript before adopting it.

If the page must run its own JavaScript before printing, start with Puppeteer or Playwright. If the content is already-rendered HTML and CSS and you want a Python or CLI workflow, consider WeasyPrint. Keep wkhtmltopdf for a known-compatible legacy case rather than assuming it will reproduce a current browser layout.

Prepare Bootstrap HTML for PDF output

Make styles and assets resolvable

The renderer must be able to load Bootstrap CSS and every linked stylesheet, image, and font. When converting a hosted page, keep those resources reachable from the page URL. For generated HTML, use absolute asset URLs or a correct <base> URL. If a stylesheet or font cannot be fetched, the PDF can still be created but look unstyled or substitute fonts.

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

Design specifically for print media

Chromium PDF output uses print CSS media by default, rather than simply taking a screenshot of the screen layout. Playwright documents the same default. That means responsive breakpoints and @media print rules can change the result: navigation, controls, shadows, backgrounds, and overflow behavior may need separate treatment. Puppeteer documents that page.pdf() generates a PDF with the print CSS media type (Puppeteer PDF API); Playwright describes its PDF method as using print CSS media (Playwright Page API).

#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs

Set page size and margins deliberately

Use CSS @page for document dimensions and margins, and make the renderer honor them. For Chromium, preferCSSPageSize: true lets the CSS page size take precedence. A4 and 12 mm margins are a starting point, not a universal fit: long tables, invoices, and forms may need different margins or orientation.

Convert a page with Puppeteer

This example opens a page, waits for network activity to settle, and writes an A4 PDF. Save it as an ES module file such as make-pdf.mjs, install Puppeteer in the project, then run it with Node.js.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.test/invoice', {
    waitUntil: 'networkidle2'
  });

  await page.pdf({
    path: 'invoice.pdf',
    format: 'A4',
    printBackground: true,
    preferCSSPageSize: true,
    margin: {
      top: '12mm',
      right: '12mm',
      bottom: '12mm',
      left: '12mm'
    }
  });
} finally {
  await browser.close();
}

Replace the example URL with your page. Puppeteer’s guide uses networkidle2 as a navigation wait option before PDF generation (Puppeteer PDF generation guide). For pages that keep background requests open, or render key content after an API response, navigation settling alone may not mean the content you need is ready. Wait for a page-specific selector or another known readiness condition before calling page.pdf().

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.

Use screen media only when that is the intended output

If the PDF should preserve the screen styling rather than print styling, call await page.emulateMediaType('screen') before page.pdf(). This changes which media rules apply; it does not remove the need to check page dimensions, margins, and pagination. Playwright has a corresponding media emulation API; set it before generating the PDF if screen media is required.

Convert a page with Playwright

Playwright also uses Chromium to produce PDFs. The following is a runnable Node.js example using its Chromium browser. Install Playwright and its browser runtime in the project first.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
import { chromium } from 'playwright';

const browser = await chromium.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.test/invoice', {
    waitUntil: 'networkidle'
  });

  await page.pdf({
    path: 'invoice.pdf',
    format: 'A4',
    printBackground: true,
    preferCSSPageSize: true,
    margin: {
      top: '12mm',
      right: '12mm',
      bottom: '12mm',
      left: '12mm'
    }
  });
} finally {
  await browser.close();
}

As with Puppeteer, wait for page-specific content if the application renders important elements after navigation. For screen styling, use Playwright’s page media emulation API before page.pdf(). Leave the default print behavior in place when your CSS is designed for printing.

Convert static HTML with WeasyPrint

WeasyPrint accepts HTML strings and can also render files and URLs. Its Python API is useful when HTML is generated inside an application and you want to attach explicit CSS for page layout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from weasyprint import HTML, CSS

html_text = """
<!doctype html>
<html>
  <head>
    <link rel="stylesheet"
          href="https://cdn.example.test/bootstrap.min.css">
  </head>
  <body>
    <main class="container">
      <h1>Invoice</h1>
      <p>Static HTML rendered to PDF.</p>
    </main>
  </body>
</html>
"""

css = CSS(string="""
  @page { size: A4; margin: 12mm; }
  @media print { .screen-only { display: none; } }
""")

HTML(string=html_text, base_url="https://example.test/").write_pdf(
    "output.pdf",
    stylesheets=[css]
)

Set base_url when the HTML uses relative links, so the renderer can resolve them. You can also pass a URL, file, or file object to the HTML API. WeasyPrint supports additional CSS and custom URL fetchers for controlled asset retrieval (WeasyPrint API reference).

Do not feed untrusted HTML or CSS directly to a renderer running with broad file or network access. WeasyPrint specifically warns that untrusted HTML or CSS may create security problems (WeasyPrint security guidance). Apply input controls, isolate the rendering process, and restrict how remote or local assets can be fetched.

Write print CSS for Bootstrap layouts

Place print overrides after Bootstrap so your rules win in the cascade. The following example hides screen-only controls, allows responsive tables to use the page width, and defines A4 page margins:

Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
@page {
  size: A4;
  margin: 12mm;
}

@media print {
  .screen-only,
  .navbar,
  .btn,
  form {
    display: none !important;
  }

  .container {
    width: auto !important;
    max-width: none !important;
  }

  .table-responsive {
    overflow: visible !important;
  }

  .row {
    break-inside: avoid;
  }
}

Prevent clipped tables and overflow

Bootstrap’s responsive table wrappers may scroll horizontally on screen. In a PDF, a scrollable container can clip columns instead of showing the full table. Let the wrapper overflow visibly for print and inspect the resulting pages. If a table is wider than the printable area, reduce its content or font size, use landscape orientation, or split it into more manageable sections; merely disabling overflow cannot make an oversized table fit.

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

Check breakpoints and page breaks

Print layout can activate a narrower responsive grid than you expect. Older Bootstrap documentation notes that print viewport width may trigger a small grid breakpoint and recommends custom print media queries when that produces the wrong layout (Bootstrap 3.4 CSS documentation). A print-specific container width or column rule can correct the result. Avoid forcing every row to stay together if a row is taller than a page; it can leave large gaps or still split where the renderer cannot honor the rule.

Keep backgrounds when they carry meaning

For Puppeteer and Playwright, set printBackground: true if the PDF needs CSS background colors or images. Check the result, because print-oriented styles or user print settings can still affect output. Do not rely on color alone to communicate status: borders, labels, or text should make the document understandable without background fills.

Bootstrap documents print visibility utilities, including .hidden-print and .visible-print-*, in older versions (Bootstrap 3.4 CSS documentation). Bootstrap’s Utility API can also generate print-only utility classes inside print media rules (Bootstrap 5.3 Utility API). Utilities differ by Bootstrap version, so check the documentation for the version actually loaded by your page rather than mixing class names across versions. Bootstrap 4’s documentation describes its print utilities and print stylesheet behavior, including page-size improvements (Bootstrap 4.6 display utilities).

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo offers a one-request API for a PDF capture. It is also a website screenshot API and MCP server for developers. For a Bootstrap URL, send a GET request and specify PDF output using the API’s documented options; this example shows the basic request pattern:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.test/invoice 
  -o invoice.pdf

See the ScreenshotNeo documentation for the PDF output parameter and other request options. ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and whether the request was billed. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free 1,000 screenshots per month, with no card required.

Troubleshoot common PDF problems

Bootstrap styles disappear

  • Likely cause: The stylesheet URL is relative to a different base path, unreachable from the renderer, or blocked by network access.
  • Fix: Use a valid absolute URL or set the correct base URL; confirm the renderer can access the stylesheet and inspect the page before generating the PDF.

Fonts or images are missing

  • Likely cause: Assets have not loaded, their URLs are inaccessible, or a font request failed.
  • Fix: Use resolvable URLs and wait for the relevant page content and assets to load. Confirm that the font and image requests succeed in the rendering environment.

Cards or columns break in unexpected places

  • Likely cause: Print media activates different responsive rules, or a layout element crosses a page boundary.
  • Fix: Add print-specific layout rules and apply page-break controls to the smallest useful unit. Generate sample PDFs with representative long and short content.

Tables are clipped

  • Likely cause: A responsive wrapper retains scrolling or the table exceeds the printable width.
  • Fix: Set visible overflow for print, then reduce columns, adjust typography, or switch to landscape if the content still does not fit.

Background fills are absent

  • Likely cause: The PDF call does not print backgrounds or print CSS removes them.
  • Fix: Set printBackground: true in Puppeteer or Playwright and review the print rules for the affected elements.

Output is blank or missing late-rendered content

  • Likely cause: PDF generation began before the application rendered its data, or navigation never reached the expected state.
  • Fix: Wait for a selector or page-specific readiness signal after navigation, and handle navigation failures instead of writing a PDF unconditionally.

Make PDF generation repeatable and safe

For consistent output across deployments, pin the renderer and Bootstrap versions, use explicit page options, and compare representative PDFs when either version changes. Browser-based rendering requires a browser runtime; WeasyPrint requires Python and its native text and layout dependencies; wkhtmltopdf is a standalone binary with an older rendering engine. Choose deployment dependencies accordingly and test the actual environment, not only a developer workstation.

Remote pages and HTML-to-PDF inputs are also a security boundary. A page can reference remote resources, while untrusted markup may attempt to load resources the rendering process should not access. Restrict input, control asset fetching, and isolate rendering workers where appropriate. WeasyPrint documents custom URL fetchers as a way to control resource retrieval, but that control still needs to be configured for the threat model.

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.

Finally, inspect real PDFs rather than treating a successful file write as proof of fidelity. Check a long table, a page boundary, a font-heavy page, missing or blocked assets, and a page with print-only content. These cases expose the most common discrepancies before the PDF pipeline is relied on in production.

Frequently Asked Questions

Does Puppeteer use print or screen CSS when creating a PDF?

Print CSS by default. Use media emulation before PDF generation if the screen media layout is specifically required.

Can WeasyPrint render a Bootstrap page with JavaScript?

WeasyPrint suits static HTML and CSS. For a page that depends on application JavaScript to render its content, use a browser renderer such as Puppeteer or Playwright.

Why does a Bootstrap responsive table lose columns in a PDF?

Its responsive wrapper may preserve horizontal scrolling, which can clip columns on a printed page. Override overflow for print and make sure the table fits the printable width.

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

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.