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.

Reserve the margin in PDF units and reset the image’s y-coordinate for every page. A split html2canvas result is one tall raster image; jsPDF will not repeat a top margin automatically. Compute contentHeight = pageHeight - topMargin - bottomMargin, place each section at y = topMargin, and call addPage() before placing each later section.

Why later pages lose the top margin

html2canvas returns a single canvas whose height may be many printed pages. When that canvas is inserted into jsPDF, the image has no knowledge of page boundaries, headers, footers, or margins. The PDF code controls the placement coordinate. If the first image starts at top but subsequent iterations use 0, those pages correctly begin at the PDF’s top edge—just not at your intended margin.

The fix is a pagination loop with three separate measurements:

  • Page dimensions: the width and height returned by jsPDF, in its configured unit.
  • Margins: top, right, bottom, and left, in that same unit.
  • Rendered image dimensions: the canvas scaled to the available content width.

Do not subtract CSS pixels from millimetres or points. Convert the canvas proportionally into the jsPDF unit first, then calculate how much of that rendered height fits on each page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)

Manual pagination with a repeated top margin

Complete working example

This example captures an element, scales it to an A4 page, leaves 12 mm above and below the content, and repeats that top margin on every page.

html2canvas(element, {
  scrollX: 0,
  scrollY: 0,
  useCORS: true
}).then((canvas) => {
  const pdf = new jsPDF({
    unit: 'mm',
    format: 'a4',
    orientation: 'portrait'
  });

  const top = 12;
  const right = 10;
  const bottom = 12;
  const left = 10;

  const pageWidth = pdf.internal.pageSize.getWidth();
  const pageHeight = pdf.internal.pageSize.getHeight();
  const contentWidth = pageWidth - left - right;
  const contentHeight = pageHeight - top - bottom;

  // Preserve the canvas aspect ratio in PDF units.
  const renderedHeight = canvas.height * contentWidth / canvas.width;
  const imageData = canvas.toDataURL('image/png');

  let remainingRenderedHeight = renderedHeight;
  let offset = 0;

  while (remainingRenderedHeight > 0) {
    if (offset > 0) {
      pdf.addPage();
    }

    const sliceHeight = Math.min(contentHeight, remainingRenderedHeight);

    // The image is taller than the page. A negative y offset exposes
    // the current section, while the page itself clips the rest.
    pdf.addImage(
      imageData,
      'PNG',
      left,
      top - offset,
      contentWidth,
      renderedHeight
    );

    remainingRenderedHeight -= sliceHeight;
    offset += sliceHeight;
  }

  pdf.save('output.pdf');
});

The key detail is that top is used on every addImage() call. The progressively more negative top - offset value moves the tall image upward to reveal the next section, but each new PDF page still starts that section at the same top margin.

How the height calculation works

  1. Read the page size after creating the document. This avoids hard-coding a value that could be wrong for A4, Letter, landscape, or a custom format.
  2. Subtract left and right margins from the page width.
  3. Scale the canvas to that content width. The proportional height is canvas.height * contentWidth / canvas.width.
  4. Subtract both top and bottom margins from the page height. That result is the drawable height for each slice.
  5. After each slice, increase the offset by the drawable height actually consumed. Add a page only when there is still image content to place.

With a 297 mm-high A4 page and 12 mm top and bottom margins, the drawable height is 273 mm. A final slice can be shorter than 273 mm; it still begins at 12 mm and never enters the reserved footer area.

A more deterministic option: create real canvas slices

The negative-offset technique relies on the PDF page clipping region. It is compact and usually sufficient, but explicit raster slices give you tighter control for very large captures, unusual viewers, or debugging page boundaries.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
html2canvas(element, { scrollX: 0, scrollY: 0, useCORS: true }).then((source) => {
  const pdf = new jsPDF({ unit: 'mm', format: 'a4' });
  const top = 12, right = 10, bottom = 12, left = 10;
  const pageWidth = pdf.internal.pageSize.getWidth();
  const pageHeight = pdf.internal.pageSize.getHeight();
  const contentWidth = pageWidth - left - right;
  const contentHeight = pageHeight - top - bottom;
  const scale = contentWidth / source.width;
  const pagePixels = Math.floor(contentHeight / scale);

  let sourceY = 0;
  let pageNumber = 0;

  while (sourceY < source.height) {
    if (pageNumber > 0) pdf.addPage();

    const slicePixels = Math.min(pagePixels, source.height - sourceY);
    const slice = document.createElement('canvas');
    slice.width = source.width;
    slice.height = slicePixels;

    const context = slice.getContext('2d');
    context.drawImage(
      source,
      0, sourceY, source.width, slicePixels,
      0, 0, source.width, slicePixels
    );

    const sliceHeight = slicePixels * scale;
    pdf.addImage(
      slice.toDataURL('image/png'),
      'PNG',
      left,
      top,
      contentWidth,
      sliceHeight
    );

    sourceY += slicePixels;
    pageNumber += 1;
  }

  pdf.save('output.pdf');
});

This version copies only the current source range and inserts it at exactly (left, top). It can reduce the amount of oversized image data held by a PDF page, although the original html2canvas canvas still exists in memory. For extremely tall documents, capture and process sections separately instead of creating one enormous canvas.

Using html2pdf.js instead of a manual loop

If you do not need custom raster pagination, html2pdf.js exposes a margin option and page-break controls. The margin accepts:

Rank #2
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.
  • A single number for all four sides.
  • [vertical, horizontal] for top/bottom and left/right.
  • [top, left, bottom, right] for independent sides.

For example, use margin: [12, 10, 12, 10] when your jsPDF unit is millimetres. Keep the unit consistent in the html2pdf.js configuration and any calculations you make yourself. If you also use the jsPDF html() integration, pass the html2canvas options through its HTML-rendering pipeline and verify the resulting page breaks rather than assuming a tall screenshot will split at semantic HTML boundaries.

When the wrapper is preferable

  • Use html2pdf.js when convenience, CSS page-break rules, and a four-value margin setting matter more than exact raster slice placement.
  • Use the manual loop when you need predictable image coordinates, custom headers or footers, or a known number of pixels per page.
  • Use explicit canvas slices when clipping behavior differs between PDF viewers or when boundary artifacts must be eliminated.

Headers, footers, and page-specific content

A repeated top margin is empty space, not a header. To draw a header, add it after creating each page and before (or after) inserting the image, using the same top value as the reserved area. Increase top to include the header’s height plus its desired gap. For a footer, reserve bottom and draw the footer inside that area after the image is placed. Never let the image’s calculated height use the full page height when a footer is required.

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

Page numbers can be added inside the loop because the current page number is known there. If the total count is needed in the header, first determine the number of slices, or add the total in a second pass after all pages exist.

Capture settings that affect pagination

Scrolling and fixed elements

html2canvas uses browser window and document APIs. Set scrollX: 0 and scrollY: 0 when you want the document’s top-left coordinate rather than the user’s current scroll position. Fixed navigation bars can appear on every captured section; hide or reposition them in a cloned document before capture if they should not repeat.

Cross-origin images

Images hosted on another origin need appropriate CORS permission. useCORS: true asks html2canvas to request them with CORS, but the remote server must send an allowing header. Otherwise the canvas can be tainted, and toDataURL() may fail or produce an incomplete capture. Proxy inaccessible assets or replace them with same-origin copies.

Lazy-loaded content and fonts

Wait until lazy images have loaded and web fonts have settled before calling html2canvas. Otherwise the captured height changes after you calculated page slices, causing missing content or unexpected blank space. A practical check is to await relevant image promises and document.fonts.ready, then measure the element again immediately before capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
HP Essential 2026 Laptop Student Business, Ultra Light, 4GB RAM, Intel CPU
  • Performance: Powered by Intel Celeron N4500 dual-core processor with up to 2.8 GHz burst frequency and 4MB L3 cache, this HP Chromebook delivers smooth multitasking for everyday computing. With 4GB LPDDR4x-2933 RAM and Intel UHD Graphics, enjoy seamless web browsing, video streaming, and productivity apps. Chrome OS boots in seconds and updates automatically, keeping your laptop secure and running at peak performance for students, professionals, and home users.
  • Immersive 14-Inch HD Display: Experience clear, vibrant visuals on the 14-inch diagonal HD (1366 x 768) anti-glare display with 250 nits brightness and 62.5% sRGB color accuracy. The micro-edge design maximizes your viewing area with an impressive 80% screen-to-body ratio, perfect for streaming movies, video calls, and document editing. The anti-glare coating reduces eye strain during extended use, making it ideal for all-day productivity and entertainment in any lighting condition.
  • Advanced Connectivity & Ports: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.3 for seamless device pairing. Equipped with versatile ports including 1 USB Type-C 10Gbps (with USB Power Delivery and DisplayPort 1.4), 2 USB Type-A 5Gbps ports, 1 HDMI 1.4b, and 1 headphone/microphone combo jack. Connect external monitors, transfer files quickly, charge your device, and expand your workspace effortlessly for maximum productivity and flexibility.
  • All-Day Battery & Premium Design: The battery keeps you powered throughout your day, while the included 45W USB Type-C power adapter ensures fast charging. Featuring a sleek modern grey finish with vertical brushing pattern on the keyboard deck, this lightweight 3.35 lb Chromebook combines style and portability. The full-size modern grey keyboard and HP Imagepad provide comfortable typing and precise navigation for work, school, or entertainment on the go.
  • Enhanced Security & Multimedia: Built-in H1 secure microcontroller protects your data and privacy with enterprise-grade security. The HP True Vision 720p HD camera with integrated dual array digital microphones delivers crystal-clear video calls and online meetings. HD Audio with stereo speakers provides rich, immersive sound for music, videos, and calls. With 64GB eMMC storage, you have ample space for essential files while Chrome OS seamlessly integrates with Google Drive for cloud storage.

Canvas size and memory

A high device scale factor and a long page multiply pixel count. Reduce the capture scale when memory is limited, process sections separately, or use the explicit-slice pattern. A PDF can still be large when every page contains a PNG; JPEG may reduce size for photographic content at the cost of text and line-art quality.

Troubleshooting common failures

Only the first page has a margin

Cause: later calls use y = 0, or a wrapper’s margin is configured for only the first page.

Fix: use top for every page and subtract both margins from contentHeight. In the negative-offset loop, keep the expression top - offset; in the explicit-slice loop, use top directly.

Content overlaps the footer

Cause: the loop uses pageHeight - top and forgets the bottom margin.

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

Fix: calculate pageHeight - top - bottom. The final slice is allowed to be shorter; do not stretch it to fill reserved footer space.

A blank page appears at the end

Cause: addPage() runs before checking whether another slice remains, or the loop treats an exact boundary as an additional page.

Rank #4
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)

Fix: add a page only when the offset or page number is greater than zero and the remaining height is positive. In a wrapper, inspect page-break settings for an empty trailing break element.

Pages are the wrong size or orientation

Cause: hard-coded dimensions do not match the configured format, orientation, or unit.

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

Fix: call pdf.internal.pageSize.getWidth() and getHeight() after constructing jsPDF, and derive every measurement from those values.

Images disappear or toDataURL() throws

Cause: a cross-origin image tainted the canvas.

Fix: enable useCORS, ensure the image server permits your origin, or serve the asset through a same-origin proxy. Also check the browser console for the first blocked resource.

Text looks blurry

Cause: the entire page is rasterized by html2canvas, then scaled down.

Fix: increase capture scale only if memory permits, keep the rendered width close to the PDF content width, or use a vector-oriented HTML/PDF workflow when selectable text is essential.

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.
Best Value
Dell OptiPlex Computer Desktop PC, Intel Core i5 3rd Gen 3.2 GHz, 16GB RAM, 2TB HDD, New 22 Inch LED Monitor, RGB Keyboard and Mouse, WiFi, Windows 11 Pro (Renewed)
  • 🖥POWERFUL PROCESSOR and SUPERIOR STORAGE: Configured with top of the Intel Core i5 processor for lightning-fast, reliable and consistent performance to ensure an exceptional PC experience. 16GB RAM memory to smoothly run multiple applications and browser tabs all at once. 2TB HDD storage space to store apps, games, photos, music, and movies. Loaded with 16GB to zip through multiple tasks in a hurry without lag.
  • 🖥️New 22 Inch Full HD (1920x1080) LED monitor: with 75hz, High-Quality panel with quick refresh rate and response time. With 1080p resolution, you can enjoy gaming or a modern computing experience. 22 Inch monitor has a Smart Contrast to provide optimized image quality. Bezel-less and sleek design with glossy finish, crisp edge-to-edge visuals. Wide Viewing Angles for clarity from any viewpoint. VESA Mountable and built-in tilt options allow for a variety of monitor configurations.
  • ⌨️ +🖱️ RGB KEYBOARD AND MOUSE | RGB SPEAKER: 3 LED Colors - Blue, red, green, Backlight LED Lights for use at night time, looks amazing. The keyboard mouse and speaker are responsive, reliable, and probably plastered in RGB lights. It's important you pick the right one for your desktop.
  • 💿 WINDOWS 10 Pro LATEST: A new installation of the latest Microsoft Windows 11 Professional 64 Bit Operating System software, free of bloatware commonly installed from other manufacturers. As Microsoft's latest and best OS to date, Windows 10 Pro 64 Bit will maximize the utility of each PC for years to come. Optional software such as Anti-Virus and Office 365 can also be easily downloaded through the Microsoft Windows App Store.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your actual goal is a clean PDF or image of a URL rather than reproducing a browser capture pipeline, ScreenshotNeo makes one GET request and returns a PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

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

See the ScreenshotNeo documentation for the request options. The same API supports full-page capture, element selectors, device and viewport settings, retina scale, PDF paper and margin controls, custom CSS and JavaScript, click and wait actions, blocked resources, headers, cookies, user agents, timezone and geolocation, transparent backgrounds, resizing, TTL-based caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is available on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to start.

Final implementation checklist

  • Configure jsPDF’s unit before calculating margins.
  • Read page width and height from the document instance.
  • Subtract left and right margins from image width.
  • Subtract both top and bottom margins from usable page height.
  • Set the image’s x-coordinate to left and its y-coordinate to top on every page.
  • Add a page only when another positive-height slice remains.
  • Test the first, middle, and final pages, including an image whose height is an exact multiple of usable page height.
  • Verify CORS, scrolling, lazy content, fonts, and memory limits before blaming pagination.

Frequently Asked Questions

Can I use pixel values for the margin?

Only after converting them to the jsPDF document unit. A CSS-pixel value cannot be subtracted directly from a page height expressed in millimetres or points.

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

Will a negative image y-coordinate crop the image?

The page clipping region hides the portion outside the page. If you need deterministic cropping independent of clipping behavior, create a temporary canvas slice and insert it at the positive top coordinate.

Why is html2pdf.js margin syntax different from CSS margin syntax?

Its margin array is interpreted in jsPDF units and uses the order top, left, bottom, right for four values, not CSS’s unit and layout rules.

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.