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.

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

Use print-specific CSS to isolate the section, then call window.print(). The browser opens its print dialog; the user can choose a PDF destination if the browser or environment offers one. This native approach needs no JavaScript library, but it cannot silently create or return PDF bytes: saving is controlled by the browser and its print interface.

Build a page that prints only the section

Give the content you want to save a stable selector, such as #snapshot. Add print rules that hide the surrounding interface and leave that section visible. The following small example includes the markup, print stylesheet and JavaScript event handler.

<section id="snapshot">
  <h1>Snapshot heading</h1>
  <p>Content to save.</p>
</section>

<button id="save-pdf" type="button">Print or save as PDF</button>

<style>
@media print {
  body * {
    visibility: hidden;
  }

  #snapshot,
  #snapshot * {
    visibility: visible;
  }

  #snapshot {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
  }

  #save-pdf {
    display: none;
  }
}

@page {
  margin: 12mm;
}
</style>

<script>
document.querySelector("#save-pdf").addEventListener("click", () => {
  window.print();
});
</script>

When the visitor clicks the button, the handler asks the browser to print the current document. The print stylesheet applies to that operation, not to the ordinary screen view. The example is a starting point rather than a universal layout recipe: existing styles, ancestors, positioning and content length can change the preview.

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

What JavaScript can—and cannot—do

window.print() opens the print dialog for the current document. It returns undefined; it does not return a PDF object, a file path or a promise that resolves when a PDF has been saved. Your code can request printing, but it cannot rely on a uniform browser interface or force a silent PDF download through this method.

#1 Best Overall
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
  • QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
  • VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
  • INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
  • EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0

The browser or user agent mediates the destination. A user may be offered an option such as Save as PDF, depending on the browser and environment. The visitor chooses that destination and any applicable print settings. Treat the result as a user-driven print workflow, not a server-style PDF export API.

If print() is called while the document is still loading, the browser waits for loading to complete before opening the dialog. The call blocks while the dialog is open. This means subsequent JavaScript execution may pause until the dialog is dismissed; do not treat it like a non-blocking background job.

Make the printed section readable

Hide the rest of the interface

@media print is the standard CSS mechanism for rules that apply to printed output. You can hide navigation, buttons and unrelated sections, adjust typography and spacing, and preserve only the content that belongs in the snapshot. Cascade specificity still matters: a more specific existing rule can override a broad print declaration. Inspect the actual print preview rather than assuming a rule wins.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
  • READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
  • WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
  • OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)

The example uses visibility: hidden for the page and restores visibility for the target and its descendants. Hidden elements still occupy layout space, which can affect positioning and page flow. The target is positioned at the upper left to reduce interference from surrounding layout, but that choice can itself interact poorly with long content, page breaks, fixed elements, or the page’s existing CSS. Test with the real page and content.

Set page dimensions and margins

Use @page to request print-page dimensions, orientation or margins where supported. The example requests a 12 mm margin. That rule does not guarantee that every browser will produce identical pages: print settings and browser behavior can affect the output. Page size, margins, headers and footers, and background graphics may also be controlled in the print UI.

@page {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  .section-heading {
    break-after: avoid;
  }

  .keep-together {
    break-inside: avoid;
  }
}

The page size and break declarations are examples of print styling to test in the browsers and environments you support; they are not a promise that all print engines will honor every detail identically. Long sections may span multiple pages, so check headings, tables and other meaningful blocks for awkward splits.

Rank #3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
  • STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
  • CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
  • HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
  • FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
  • BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer

Use print lifecycle events only when needed

The beforeprint and afterprint events can help adjust an interface around printing—for example, temporarily changing a screen-only presentation. Keep the core printable layout in CSS where possible, and verify event behavior in the target browser rather than using an event as proof that a PDF was saved. The print dialog’s destination and completion are not exposed as a returned PDF file by window.print().

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

Choose the right implementation shape

Print the current document

Use the example above when the target section already lives in the page and print CSS can isolate it reliably. It is the simplest no-library route: maintain one document, add a print presentation and ask the browser to print.

Use a dedicated print document or iframe for complex pages

If the live page has complicated application styling, a separate print document or print iframe can isolate the content and its layout. This adds document setup and may require copying or recreating the styles the section needs. It is not automatically more reliable: confirm that fonts, images and CSS are available in the print document, then inspect the resulting preview.

Rank #4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
  • IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
  • IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
  • IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
  • Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management

Know what this route is not

Browser print-to-PDF is appropriate when a person can interact with the print UI. If your application needs PDF bytes returned to JavaScript, a predictable automatic download, or a server-side capture workflow, window.print() does not supply those capabilities. Those requirements call for a different approach; this article’s native workflow should not be represented as a programmatic PDF-generation API.

Troubleshooting the print preview

  • The whole page appears: Check that the intended element actually matches #snapshot, and inspect computed print styles for rules overriding visibility or hiding the target. Confirm that the print stylesheet applies in preview.
  • The target is missing or clipped: Check whether an ancestor, overflow rule, positioning context or inherited style affects it. Try a simpler print layout and review the target’s width and positioning over multiple pages.
  • There is a large blank area: The visibility: hidden pattern leaves other elements in the layout. Review the target’s position and the surrounding document flow; a dedicated print document may be easier to control on a complex page.
  • Content breaks in the wrong place: Check long blocks, fixed or sticky elements and page-break rules in preview. Print pagination differs from ordinary scrolling layout, so test representative long content rather than only a short sample.
  • Margins, backgrounds or headers differ: Review the browser’s print settings as well as @page and print CSS. The dialog may control settings that the page cannot guarantee.
  • The dialog does not open in an embedded page: A document sandbox can block printing. Check the embedding and sandbox permissions, and test in the actual host browser. In the blocked case, the print dialog is blocked and neither beforeprint nor afterprint fires.
  • The code continues only after the dialog closes: This is expected: the print call blocks while the dialog is open. Do not use the call’s return value as a signal that a PDF was created.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and user expectations

This method avoids adding a PDF-generation JavaScript library, but it still relies on the browser’s print implementation and the user’s choices. Its output can vary with print settings and the page’s styles. There is no PDF payload for your application to cache or inspect through the return value of window.print(), and there is no verified speed or adoption figure to apply to this workflow.

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

For dependable user experience, label the control accurately—for example, “Print or save as PDF”—and tell users that they must choose a PDF destination in the print dialog if one is available. Keep screen-only controls out of print output, test the preview at realistic content lengths, and avoid promising exact page layout when the browser and print settings remain outside your control.

Best Value
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images

Or skip the browser setup

If your goal is a URL-based capture rather than printing a section already open in a visitor’s browser, ScreenshotNeo offers a screenshot API and MCP server. Its API is a separate capture workflow, not a replacement for the browser-native section-selection example above. The service supports screenshots or PDFs and provides a selector option for element capture; use the documentation to configure a capture for your page. See the ScreenshotNeo API documentation.

A one-request screenshot example, following the documented request pattern, is:

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://stripe.com 
  -o shot.webp

The example writes a WebP screenshot. ScreenshotNeo can also return a PDF; consult its API documentation for the appropriate output configuration. Cookie and consent banners, newsletter popups and chat widgets are removed before capture, with each cleanup step able to be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed; response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000 shots. Sign up for the free plan.

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

Sources and scope

The browser behavior and print-CSS guidance here follow MDN’s documentation for CSS printing and the Window.print() method, plus the WHATWG HTML Standard’s printing provisions. The behavior described is the browser-native workflow; exact UI and output can vary by browser and environment.

Frequently Asked Questions

Does window.print() tell me when the PDF has been saved?

No. It returns undefined and does not expose the saved file or a save-completion promise.

Can JavaScript force every browser to download the PDF silently?

No. The native print workflow opens a browser- or user-agent-controlled dialog, and PDF saving is an available destination only where that environment offers it.

Can a sandboxed embedded document print?

A document sandbox can block printing. Check the embedding permissions and test the behavior in the host environment.

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

Quick Recap

Bestseller No. 3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer; This product is not intended for scanning photographs on photo paper / photographic media
$184.00
Bestseller No. 4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
Find our Software here : irislink.com/start; IRIScan Express is only compatible Windows platform and not macintosh
$129.00
Bestseller No. 5
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Scanner type: Document; Connectivity technology: USB; With Auto Scan Mode, the scanner automatically detects what you're scanning
$75.00

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.