Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Canvas

How to Split an Image Across Two PDF Pages With jsPDF

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.

To split a tall image across two PDF pages with jsPDF, crop it into two adjacent pieces and place one piece on each page with addImage. jsPDF’s documented image API places an image at explicit coordinates and dimensions; it does not document an automatic split option. The method below preserves scale and continuity by deriving both crops from the same source image.

Why you need to crop the image yourself

addImage takes image data plus an explicit placement rectangle: an x-coordinate, y-coordinate, width, and height in the PDF document’s configured units. Its documented API does not list a setting that automatically divides an oversized image between pages. The reliable approach is to crop the source into page-sized image segments, then add each segment to its own page. See the jsPDF type declarations for the relevant API signatures.

This technique is appropriate when the image itself is the content you want in the PDF. The crops remain raster images; text or graphics flattened into the source will not become selectable PDF text.

Set up the page and calculate the crop

Choose the PDF page format, orientation, unit, and margins before calculating crop dimensions. jsPDF supports standard page formats and custom page dimensions, as described in its constructor documentation. The code below uses A4 portrait pages, millimeters, and 10 mm margins. Change those values to match your layout.

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.
#1 Best Overall
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

The drawing canvas has pixel dimensions, while addImage uses the PDF unit you selected. To preserve the image’s aspect ratio, first choose a display width. Then calculate the displayed height from the canvas aspect ratio. The maximum displayed height per page is the page height minus the top and bottom margins.

Convert that available display height back to source pixels to find where the first crop ends. The second crop starts at exactly that source-pixel row. Both pieces use the same display width, which avoids a size jump or gap at the page break.

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)

Complete browser example

This example assumes an image is available at imageUrl and that jsPDF is loaded in the page. It draws the image onto a source canvas, creates two crops, and places them on consecutive pages. The first page receives as much of the image as fits in the content area; the second receives the remaining rows.

// Load jsPDF in the page, for example with a script tag that exposes window.jspdf.jsPDF.
const { jsPDF } = window.jspdf;

function loadImage(url) {
  return new Promise((resolve, reject) => {
    const img = new Image();
    img.onload = () => resolve(img);
    img.onerror = () => reject(new Error(`Could not load image: ${url}`));
    img.src = url;
  });
}

async function splitImageAcrossTwoPages(imageUrl) {
  const img = await loadImage(imageUrl);

  // Render the source at its natural pixel dimensions.
  const source = document.createElement('canvas');
  source.width = img.naturalWidth;
  source.height = img.naturalHeight;
  const sourceCtx = source.getContext('2d');
  if (!sourceCtx) throw new Error('Could not create a 2D canvas context');
  sourceCtx.drawImage(img, 0, 0);

  const pdf = new jsPDF({
    orientation: 'portrait',
    unit: 'mm',
    format: 'a4'
  });

  const margin = 10;
  const pageWidth = pdf.internal.pageSize.getWidth();
  const pageHeight = pdf.internal.pageSize.getHeight();
  const contentWidth = pageWidth - margin * 2;
  const contentHeight = pageHeight - margin * 2;

  // Fit the image to the available width, retaining its aspect ratio.
  const displayWidth = contentWidth;
  const pixelsPerUnit = source.width / displayWidth;
  const firstCropPixelHeight = Math.min(
    source.height,
    Math.floor(contentHeight * pixelsPerUnit)
  );

  if (firstCropPixelHeight <= 0) {
    throw new Error('The page content area is too small for this image');
  }

  function makeCrop(startY, cropHeight) {
    const canvas = document.createElement('canvas');
    canvas.width = source.width;
    canvas.height = cropHeight;
    const ctx = canvas.getContext('2d');
    if (!ctx) throw new Error('Could not create a crop canvas context');
    // drawImage source-rectangle form: crop exactly the requested source rows.
    ctx.drawImage(
      source,
      0, startY, source.width, cropHeight,
      0, 0, canvas.width, canvas.height
    );
    return canvas;
  }

  const firstCrop = makeCrop(0, firstCropPixelHeight);
  const firstDisplayHeight = firstCropPixelHeight / pixelsPerUnit;
  pdf.addImage(
    firstCrop,
    'PNG',
    margin,
    margin,
    displayWidth,
    firstDisplayHeight
  );

  const remainingPixelHeight = source.height - firstCropPixelHeight;
  if (remainingPixelHeight > 0) {
    const secondCrop = makeCrop(firstCropPixelHeight, remainingPixelHeight);
    const secondDisplayHeight = remainingPixelHeight / pixelsPerUnit;
    pdf.addPage('a4', 'portrait');
    pdf.addImage(
      secondCrop,
      'PNG',
      margin,
      margin,
      displayWidth,
      secondDisplayHeight
    );
  }

  pdf.save('split-image.pdf');
}

splitImageAcrossTwoPages('/images/tall-image.png').catch(console.error);

The cropping step uses the canvas 2D drawImage overload with source and destination rectangles; the jsPDF declarations include that overload as well as addPage and page-size accessors. See the declarations for those interfaces.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Plustek PS186 Desktop Document Scanner, with 50-Pages Auto Document Feeder (ADF). for Windows 7/8 / 10/11 (Intel/AMD only)
  • Up to 255 customize favorite scan file setting with "Single Touch" , Support Windows 7/8/10
  • Turn paper documents into searchable, editable files - save scans as searchable PDF files; OCR function included
  • Info Barcode function - automatic categorization of complicate documentation and data with 1D or 2D Barcode page.
  • Intelligent color and image adjustments — Auto Rotate, Crop, Deskew and blank page remove with Plustek Image Processing Technology
  • Easy send scanned files to FTP server or personal NAS (FTP) with PDFs , Jpeg , TIFF or Png format. User can download scanner driver from Plustek website

When the image is shorter or longer than two pages

If the image fits within the first page’s content height, the code creates only one page. If the remainder is taller than one page, this two-page example is not enough: repeat the crop-and-add process in a loop, taking at most Math.floor(contentHeight * pixelsPerUnit) source rows per page until all source rows are used. Add each new page before placing its crop.

Adapting the layout

  • Landscape or another paper size: change the constructor’s orientation or format before reading page dimensions.
  • Custom dimensions: supply the desired page dimensions when constructing the PDF, then use getWidth() and getHeight() rather than hard-coded page values.
  • Different margins: update margin; the crop calculation uses the available height after top and bottom margins.
  • Different display width: choose a width no larger than pageWidth - 2 * margin. The crop pixel height is recalculated from that width, preserving the source aspect ratio.
  • More or less image clarity: retain sufficient source pixels for the intended printed or on-screen size. Enlarging a low-resolution source cannot restore detail.

Important edge cases

Images loaded from another origin

A browser may refuse to draw a cross-origin image into a canvas unless the image host permits it through CORS. If the canvas becomes tainted, exporting or using its pixel data can fail. Serve the image from your own origin or configure the remote host’s CORS response appropriately; setting img.crossOrigin alone does not grant permission.

Rank #4
Hczrc Portable Scanner, Photo Scanner for A4 Documents, Handheld Scanner for Business, Photo, Picture, Receipts, Books, JPG/PDF Format Selection, UP to 900 DPI, with 16G SD Car
  • Note: No software installation is required. You need 2 AA batteries ( not included) and a memory card ( included) to use it directly. Scan mode: Press and hold "Scan" for 2 seconds to turn on the device, and then press "Scan", the green light is on. The scanner moves to scan the file until the green light turns off automatically (or press the "Scan" key and the green light goes out). The number shown on the display increases by 1 to indicate that the scan is complete.
  • Portable Scanner scans images or pictures quickly: Store JPEG/PDF files within seconds, scan images or pictures quickly, plug and play, no need any software preinstalled. Compatible with Windows XP/7/Vista/Mac OS 10.4 or above version.
  • Lightweight and travel-friendly: Stored in Micro SD card directly, support read data on your computer or phone with USB connected. Powered by 2pcs AA batteries, Compact Design, it is convenient to carry outside.
  • 3 Image Resolution: 3 modes of resolution for your options: 300dpi/600dpi/900dpi, you can save it at the clearest way, picture and document are showed clear as it is. Freely choose your favorite resolution.File Format: JPEG/PDF format is all available, Great storage capacity as it supports 32G Micro SD card(Included 16GB Card),total meet your need for business trip or daily use.
  • Widely Used: It is applicable in bank, insurance business, real estate agency,home, office, library or outdoors. suitable for lawyer, businessmen, students, travelers and amateur archivists. Scan your important files and save them immediately, no struggling in finding a printing shop, keep it confidential.

Transparent images and output format

PNG retains transparency, while formats such as JPEG do not. If you use JPEG crops, put an appropriate background behind the image before exporting or expect transparency to be flattened. The sample passes canvas data to addImage as PNG.

Very large source images

Canvas buffers and crop canvases can consume substantial memory, particularly if the whole image and several crops coexist. The API references do not establish quantitative memory limits or performance benchmarks. For unusually large images, process one crop at a time, release canvases when finished, and test with the actual image sizes and browsers your application supports.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
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

Page seam and rounding

The first crop height is rounded down to a whole source pixel. The next crop begins at that exact row, so source content is neither skipped nor duplicated. Inspect the generated PDF in the browser and PDF viewer relevant to your application to confirm the seam and image clarity.

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

Troubleshooting

  • The image is clipped or extends beyond the page: confirm margins, page format, orientation, and units are set before calculating dimensions. Use the measured page size and subtract both margins.
  • The second page is blank: check that the source image is taller than the first crop and that the remainder height is positive. Verify the page was added before the second addImage call.
  • The second crop repeats or skips part of the picture: its source start row must be exactly firstCropPixelHeight, with no extra offset or overlap.
  • The image changes size at the break: use one pixelsPerUnit value and the same display width for both crops. Do not independently fit each crop to the page.
  • Canvas export fails: investigate cross-origin restrictions and CORS headers, or test with a same-origin image.
  • The PDF is huge or the browser runs out of memory: reduce source dimensions if the required output resolution permits it, and avoid keeping unnecessary full-size crop canvases alive.
  • Text in the image is not selectable: that is expected because this workflow places raster crops. For selectable text or vector output, build the page content directly instead of flattening it into one image.

Or skip the browser setup

If what you need is a screenshot of a live web page rather than a pre-existing image, ScreenshotNeo can return a screenshot or PDF from one GET request. For API parameters and options, see the ScreenshotNeo documentation.

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

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers identifying the page verdict and billing status. Its MCP server provides screenshot and PDF tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

When not to use this method

Use crop-per-page when you have a raster image that must continue across a page break. If your source is HTML or text and you need selectable text, sharp vector elements, or document-style flow, generate the PDF from that content instead of first turning the entire page into one image. jsPDF’s declarations include HTML options such as autoPaging, but that does not establish automatic pagination for arbitrary image data passed to addImage.

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

Frequently Asked Questions

Does jsPDF automatically split an image that is taller than a page?

The documented addImage API specifies placement coordinates and dimensions, not an automatic image-splitting parameter.

Can I split a tall image across more than two PDF pages?

Yes. Repeatedly crop at the maximum source-pixel height that fits the page content area, add a page for each crop, and continue until no source rows remain.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.