To export several images into one PDF with jsPDF, create one jsPDF document, call addImage() once for each image, and call addPage() whenever the next image needs a new page. Calculate the displayed width and height from each image’s aspect ratio so it is not distorted, then call save() to download the file.
This guide covers one-image-per-page PDFs, contact sheets, browser loading, image formats, repeated PNG issues, cross-origin failures, memory limits, and a ready-to-run implementation.
How jsPDF places multiple images
addImage() inserts one image at a time. It accepts a data URL, HTMLImageElement, HTMLCanvasElement, Uint8Array, or RGBA image data. You must provide the image format, x and y coordinates, width, and height in the document’s units. JPEG, PNG, and WEBP are documented formats; verify WEBP support in the browser and jsPDF release you deploy.
There are two basic layouts:
- One image per page: call
addPage()before every image after the first. - Contact sheet: keep using the current page, advancing x and y positions in a grid, and add a page when the next row would exceed the usable height.
One image per PDF page
The following browser module accepts an array of already-loaded image elements or canvases. It creates A4 pages in millimetres, centers each image, and fits it inside 10 mm margins without changing its aspect ratio.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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
import { jsPDF } from "jspdf";
async function imagesToPdf(images) {
const pdf = new jsPDF({ unit: "mm", format: "a4" });
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
const margin = 10;
for (let i = 0; i < images.length; i += 1) {
if (i > 0) pdf.addPage();
const image = images[i];
const ratio = image.width / image.height;
if (!Number.isFinite(ratio) || ratio <= 0) {
throw new Error(`Image ${i + 1} has no usable dimensions`);
}
const maxWidth = pageWidth - margin * 2;
const maxHeight = pageHeight - margin * 2;
const width = Math.min(maxWidth, maxHeight * ratio);
const height = width / ratio;
const x = (pageWidth - width) / 2;
const y = (pageHeight - height) / 2;
const format = image instanceof HTMLCanvasElement ? "PNG" : "JPEG";
pdf.addImage(image, format, x, y, width, height, `image-${i}`, "FAST", 0);
}
pdf.save("images.pdf");
}
The alias (the seventh argument) gives each image resource a distinct name. The final rotation argument is 0. Change the format to PNG for transparent PNG images or to WEBP when your target environment supports it.
Load files selected by the user
A file input returns File objects, not image elements. Convert each file to an object URL, wait for its dimensions, and revoke the URL after loading. This example preserves each file’s detected MIME type and passes the resulting image element to the PDF function.
function loadImageFile(file) {
return new Promise((resolve, reject) => {
const url = URL.createObjectURL(file);
const image = new Image();
image.onload = () => {
URL.revokeObjectURL(url);
resolve({ image, format: file.type === "image/png" ? "PNG" :
file.type === "image/webp" ? "WEBP" : "JPEG" });
};
image.onerror = () => {
URL.revokeObjectURL(url);
reject(new Error(`Could not decode ${file.name}`));
};
image.src = url;
});
}
async function exportSelectedFiles(fileList) {
const loaded = await Promise.all([...fileList].map(loadImageFile));
const pdf = new jsPDF({ unit: "mm", format: "a4" });
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
const margin = 10;
loaded.forEach(({ image, format }, index) => {
if (index) pdf.addPage();
const ratio = image.naturalWidth / image.naturalHeight;
const width = Math.min(pageWidth - 2 * margin,
(pageHeight - 2 * margin) * ratio);
const height = width / ratio;
pdf.addImage(image, format, (pageWidth - width) / 2,
(pageHeight - height) / 2, width, height, `file-${index}`, "FAST");
});
pdf.save("images.pdf");
}
// document.querySelector("input[type=file]").addEventListener("change", e =>
// exportSelectedFiles(e.target.files));
Use naturalWidth and naturalHeight for an HTMLImageElement; they describe the source pixels even when CSS resizes the displayed element.
Put several images on each page
For thumbnails or a contact sheet, do not add a page for every image. Track the current column and row, and test the next image against the usable page height before placing it.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsfunction contactSheet(images, columns = 2) {
const pdf = new jsPDF({ unit: "mm", format: "a4" });
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
const margin = 10;
const gap = 5;
const cellWidth = (pageWidth - 2 * margin - gap * (columns - 1)) / columns;
const cellHeight = 70;
let column = 0;
let y = margin;
images.forEach((image, index) => {
if (y + cellHeight > pageHeight - margin) {
pdf.addPage();
y = margin;
column = 0;
}
const ratio = image.width / image.height;
const width = Math.min(cellWidth, cellHeight * ratio);
const height = width / ratio;
const x = margin + column * (cellWidth + gap) + (cellWidth - width) / 2;
const imageY = y + (cellHeight - height) / 2;
pdf.addImage(image, "JPEG", x, imageY, width, height,
`contact-${index}`, "FAST");
column += 1;
if (column === columns) {
column = 0;
y += cellHeight + gap;
}
});
pdf.save("contact-sheet.pdf");
}
This uses a fixed cell height, so unusually tall images are scaled to fit. For captions, reserve additional vertical space and draw text with jsPDF’s text methods after each image.
Choosing units, page sizes, and image dimensions
Document units
Set unit to mm, pt, or another supported jsPDF unit, then use that unit consistently for margins and coordinates. The PDF does not infer a physical size from an image’s pixel dimensions; your code decides how many document units the image occupies.
Rank #2
- 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⁴
Aspect-ratio fitting
For a source ratio r = sourceWidth / sourceHeight, first limit the width and height to the available rectangle. A width of min(maxWidth, maxHeight × r), followed by height = width / r, fits the image without cropping or stretching. Centering uses (pageWidth - width) / 2 and (pageHeight - height) / 2.
Portrait and landscape pages
Use new jsPDF({ unit: "mm", format: "a4", orientation: "landscape" }) for landscape pages. If orientation should follow each image, create a document with the first orientation and pass "landscape" or "portrait" to addPage() for subsequent pages, then recalculate page dimensions after changing pages.
Formats, compression, and transparency
- JPEG: suitable for photographs and usually smaller, but it does not preserve transparency.
- PNG: preserves transparency and sharp text or line art. Use the
"PNG"format explicitly. - WEBP: listed by the API, but test the exact browser and jsPDF version used by your application.
The compression argument shown as "FAST" is a jsPDF image-compression setting. The best setting depends on source dimensions, format, and acceptable output size; there is no universal speed or file-size figure. Very large source images can consume substantial browser memory, so resize them before conversion when print resolution does not require the original pixels.
Repeated PNGs showing the wrong image
A reported jsPDF issue describes repeated PNG data URLs rendering as the first image. The targeted workaround is to pass the canvas object directly instead of repeatedly passing equivalent data URLs and to provide a distinct alias for every image, such as image-0, image-1, and so on. This addresses the reported case; it is not a guarantee for every version or input path.
Browser constraints and reliable loading
Cross-origin images
Images loaded from another origin may taint a canvas unless that server sends suitable CORS headers. A tainted canvas cannot be read with toDataURL() or similar APIs. Host the assets on the same origin, configure CORS on the image server, or use a server-side capture workflow.
Wait for decoding
Do not calculate dimensions before the image has loaded. For existing image elements, await image.decode() when available, or listen for load. Reject failed loads so the PDF is not silently generated with missing pages.
Recommended Free Tools
Rank #3
- 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.
Empty input
Handle an empty array before creating a document, or you may download a PDF with no meaningful content:
if (!images.length) throw new Error("Select at least one image");
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting
“addImage is not a function”
Make sure the package is imported from jspdf and that you are calling the method on the jsPDF instance, for example pdf.addImage(...), not on the image element.
The PDF downloads but a page is blank
Check that the image’s load or decode promise completed, its width and height are nonzero, and the format argument matches the actual bytes. A canvas with a cross-origin source may also be tainted.
The image is stretched
Do not pass arbitrary width and height values. Compute one dimension from the source ratio and fit both dimensions inside the page or grid cell as shown above.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Only the first of several PNGs appears
Pass each canvas object directly and assign unique aliases. Also ensure your loop is not reusing a single canvas that is overwritten before jsPDF reads it.
The browser becomes unresponsive
Reduce source dimensions, process files in smaller batches, release object URLs, and avoid keeping duplicate data URLs, canvases, and decoded images in memory simultaneously. Exact limits vary by browser, device, image count, and dimensions.
Rank #4
- 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
Or skip the browser setup
If the images are web pages or other URLs you need to capture, ScreenshotNeo provides a single HTTP request instead of maintaining browser automation. It accepts consent banners like a visitor and 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 as clean shots; the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
For a PDF capture, use the API’s PDF options (paper size, margins, landscape, and page ranges) or combine returned images with the jsPDF layouts above. See the ScreenshotNeo documentation for parameters.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. Create a free ScreenshotNeo account.
Cost and reliability considerations
jsPDF runs in the user’s browser, so there is no per-page service charge, but the user’s CPU and memory determine how much work can be completed reliably. Keep the document in the same unit system, release temporary objects, and test the largest realistic image set on supported devices.
For server-side or URL-based capture, ScreenshotNeo bills only clean shots and reports billing status in response headers. Its plans are Free (1,000/month), Starter ($5 for 3,000), Growth ($15 for 15,000), Pro ($39 for 60,000), Scale ($99 for 250,000), and Business ($249 for 1,000,000); yearly billing gives two months free.
Frequently Asked Questions
Can I add an image from a Uint8Array instead of an HTML image?
Yes. jsPDF’s addImage API accepts Uint8Array input; provide the correct format and explicit coordinates and dimensions.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallDoes addImage automatically create a new page?
No. It places the image on the current page. Your code must call addPage() and reset layout coordinates when another page is needed.
How do I preserve transparent backgrounds?
Use a PNG source and pass “PNG” as the format. JPEG cannot preserve transparency.
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.




