ScreenshotNeo

BlogHTML to image & PDF

How to Save a Webpage as PDF with Lazy-Loaded Images

Save a webpage as a PDF and reduce missing images by letting below-the-fold content load, checking print preview, and verifying the finished file.

By the ScreenshotNeo team4 October 20268 min read

To save a webpage as a PDF with its lazy-loaded images, let the page render, scroll through the sections you need and wait for images to appear, then open print preview, choose a PDF destination, and inspect the saved file. Scrolling is a practical precaution because lazy loading often waits until an image approaches the viewport; it cannot guarantee success for custom scripts, blocked resources, or network failures.

For a quick browser workflow:

  1. Open the page and wait for its initial content to appear.
  2. On a long page, scroll through the sections you want in the PDF. Pause if images are still appearing.
  3. Open the browser’s Print command and inspect the preview for blank image areas, missing sections, or unwanted page breaks.
  4. Choose Save to PDF (or the equivalent PDF destination) and save.
  5. Open the saved PDF and check image-heavy pages. If images are missing, return to those sections, scroll and wait, then print again.

Why lazy-loaded images can be missing

Lazy loading defers fetching an offscreen image until it is near the viewport. A page may use the native HTML loading="lazy" attribute or custom JavaScript to defer images. MDN notes that lazy images may not be available when the window load event fires, so seeing the page’s initial load complete does not prove that every below-the-fold image is ready. MDN’s loading guidance explains this distinction.

Google’s documentation says that browser-level lazy-loaded images and iframes are immediately loaded when a page is printed. That describes browser-level behavior; it is not a guarantee for every site. Custom scripts, galleries that require interaction, blocked requests, or a slow or failed network resource can still leave gaps. Google’s browser-level lazy-loading guide documents the print behavior and its scope.

Browser steps: save a complete PDF

1. Let the page settle

Wait for the initial text and visible images. If the page has a consent dialog or a “load more” control that gates content you need, handle it as a normal visitor would before printing. A PDF can only include content the page has made available to the browser.

2. Scroll through the relevant content

For a long article or gallery, move down through the sections that should appear in the PDF. Pause where image placeholders are still being replaced. This gives viewport-triggered resources an opportunity to load. It is a practical inference from how lazy loading works, not a universal or experimentally guaranteed workaround.

Do not assume that reaching the bottom means every asset succeeded. Look for persistent placeholders, broken-image icons, or areas that remain blank. Some sites load images only after a click or use custom scripts that do not respond to ordinary scrolling.

3. Inspect print preview

Open Print (often in the browser menu or with Ctrl+P on Windows/Linux or Command+P on macOS). Review the preview before saving. Check that expected images and sections are present, that columns or captions are readable, and that page breaks do not cut off important content.

Firefox’s print interface includes settings such as destination, orientation, page selection, color, paper size, scale, margins, simplified format, backgrounds, and headers and footers. The exact controls vary by browser and version. Mozilla also notes that print output can look different from the screen. See Mozilla’s Firefox print guide.

4. Save and verify the actual PDF

Choose the browser’s PDF destination and save the file. Open it afterward and inspect the pages most likely to contain deferred images. Preview is a useful check, but the saved PDF is the deliverable. If an image is absent, go back to the webpage, scroll to its section, wait for rendering, and create a fresh PDF.

Automate PDF capture with Chrome Headless

For repeatable captures, Chrome Headless can write a page to PDF from the command line. The following command saves https://example.com/ as output.pdf in the current directory:

chrome --headless --print-to-pdf https://example.com/

To omit the printed header and footer:

chrome --headless --print-to-pdf --no-pdf-header-footer https://example.com/

Chrome documents --timeout as a maximum wait before capture, even if the page is still loading. It bounds the wait; it does not confirm that all image requests completed. For example:

chrome --headless --print-to-pdf --timeout=5000 https://example.com/

The --virtual-time-budget option can fast-forward time-dependent page code such as timers, but it likewise is not proof that every image loaded:

chrome --headless --print-to-pdf --virtual-time-budget=42000 https://example.com/

Use the flags supported by the Chrome version installed in your environment. The current no-header/footer flag replaced an older name; older versions may require --print-to-pdf-no-header. See the Chrome Headless command-line reference.

When command-line capture is not enough

A fixed timeout cannot know whether a particular lazy image is complete. A page may defer content until scrolling, interaction, authentication, or client-side state. If a scripted PDF is missing images, first inspect the site’s own export option and confirm that the page’s image requests are not failing. For automation that needs precise readiness checks, use a browser automation workflow that waits for the relevant content; a simple print flag alone does not provide that condition.

Setting When to use it What to check
Orientation Use landscape for wide tables or diagrams; portrait for ordinary articles. Confirm the page is not shrinking text excessively.
Scale and margins Adjust when content clips or page breaks split a layout awkwardly. Very small scale can make text and labels hard to read.
Background graphics Enable when background colors or images carry meaning. Background printing may increase ink or file size and is not always enabled by default.
Simplified format Try it for a cluttered article when you want a reading layout. It may remove visual elements; Firefox notes simplified format disables print backgrounds.
Pages and headers/footers Select a range or remove browser-generated metadata when appropriate. Check that page numbers, URL, or date are included only if useful.

Changing layout settings can improve readability, but it will not repair an image that never loaded in the page. Recheck preview after changing settings.

Troubleshooting missing images

Symptom Likely cause What to try
Images below the first screen are blank in the PDF They had not been fetched or rendered before capture, or the site uses custom lazy loading. Return to the webpage, scroll through those sections, wait for the images to render, then print again.
Some images remain blank after scrolling The resource may be blocked, unavailable, or gated behind interaction; a custom loader may need a specific trigger. Try the page’s own download/export feature, check whether the image appears on the live page, and retry after the relevant interaction.
Preview contains images but the saved PDF does not The PDF output may differ from the preview or capture may have occurred while content was changing. Save a fresh copy and inspect it again; wait for page changes to finish before printing.
Only backgrounds or decorative images are absent Print backgrounds may be disabled or simplified format may suppress them. Enable background graphics and turn off simplified format if you need those elements.
Text or images are clipped Paper size, orientation, scale, or margins do not fit the page layout. Try landscape for wide content, adjust scale or margins, and check every affected preview page.
Headless PDF has missing images The capture timeout elapsed while resources or scripts were still working; fixed waits do not guarantee image readiness. Use a longer appropriate wait as a diagnostic, and add page-specific readiness handling in your browser automation. Confirm that the source images load successfully.
Repeated attempts fail for one site The page’s custom behavior or resource failures may not be addressed by ordinary scrolling or printing. Use a site-provided export/download if available. There is no universal browser setting that guarantees every arbitrary page will print all images.

Performance, reliability, and file size

Scrolling a long page adds time because the browser must render newly visible content and fetch deferred resources. For manual use, focus on the sections that belong in the PDF and wait only while their images are still appearing. In automated runs, a timeout caps waiting time but trades completeness against speed; too short a wait can capture unfinished content, while a longer wait still cannot fix a failed request.

PDF size depends on page content and print settings. Large or numerous images can make a file larger, while simplifying the page or omitting backgrounds may reduce visual detail. Keep the original PDF and verify image-heavy pages when fidelity matters. The sources consulted do not establish a success rate or a universally reliable timing value for arbitrary websites.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server from ScreenshotNeo. Its API returns a screenshot or PDF from one GET request. For a PDF, request the PDF output as described in the ScreenshotNeo API documentation. Here is the one-call screenshot form using the documented endpoint and a page URL:

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

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; 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 billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

FAQ

Does scrolling guarantee every lazy image will be in the PDF?

No. It can prompt viewport-based images to load, but cannot guarantee custom JavaScript behavior, accessible resources, or network success.

Should I wait for the window load event before printing?

It is useful for initial page loading, but MDN notes lazy images may not be available at that event. Check the relevant page sections themselves.

Will Chrome Headless always load lazy images when printing?

Chrome documents immediate loading for browser-level lazy images and iframes during printing. That does not guarantee success for all custom loaders, failed requests, or page states.

What if only a few images are missing?

Retry after visiting the affected sections and waiting for rendering. If those images still fail, check the site’s own export feature or whether the images load on the webpage at all.