Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsTo make an html2canvas image fit a printed page, control two separate sizes: the canvas render resolution and the size at which the image is placed in the PDF. Capture the complete element at an intentional scale, then give jsPDF a target page width and calculate the height from the canvas aspect ratio. If the resulting height is taller than one page, split the canvas or capture page-sized sections instead of squeezing the entire document.
Understand which setting controls which size
html2canvas creates a bitmap. Its scale option changes the bitmap’s internal pixel density; it does not choose A4, Letter, margins, or any physical paper dimension. The project documentation describes the default as window.devicePixelRatio and recommends matching the device pixel ratio for sharper retina rendering: html2canvas examples.
jsPDF places that bitmap on a PDF page. Its addImage call receives a width and height in the PDF’s units, such as points or millimetres. The jsPDF HTML documentation notes that output also depends on html2canvas’s scale and windowWidth: jsPDF HTML module.
- Render dimensions:
scale,width,height,windowWidth, andwindowHeightdetermine which pixels are produced. - Crop origin:
xandyselect an offset within the source; they do not define paper size. - Printed placement: jsPDF’s page format, margins, and
addImagewidth and height determine how large the image appears on paper.
Measure the complete area before rendering
A viewport-sized capture is the usual reason the bottom or right side of a page is missing. For a full element, read scrollWidth and scrollHeight, and pass those values to both the capture dimensions and the virtual browser window:
#1 Best Overall
const element = document.querySelector('#capture');
const sourceWidth = element.scrollWidth;
const sourceHeight = element.scrollHeight;
The html2canvas FAQ warns that oversized canvases can become blank or only partly render without throwing an error. It recommends matching windowWidth and windowHeight to the element’s scroll dimensions: html2canvas FAQ. If those dimensions are extremely large, render sections or pages separately rather than continuously increasing the scale.
Choose a scale deliberately
| Goal | Starting choice | Trade-off |
|---|---|---|
| Exact source pixel dimensions or lowest memory use | scale: 1 |
Fewer source pixels can make small text look soft when enlarged in the PDF. |
| Sharp ordinary print output | A moderate value such as scale: 2 |
More memory and a larger bitmap; reduce it if rendering fails. |
| Retina-style display capture | Match window.devicePixelRatio, as shown in the examples |
On a high-density display, the resulting canvas can be very large. |
Keep the PDF insertion width unchanged when testing sharpness. Increasing scale should add source pixels, not enlarge the image on the page. There is no universal maximum canvas dimension: browser and device limits differ, and failure may be silent. A smaller scale or page splitting is safer than assuming a particular limit.
Working single-page example with html2canvas and jsPDF
Load html2canvas and jsPDF in your page, give the content an identifiable element such as id='capture', and call this function from a button. It captures the full scrollable area, keeps the image proportional, and leaves a 24-point margin on an A4 portrait page.
async function printCapture() {
const element = document.querySelector('#capture');
if (!element) throw new Error('Missing #capture element');
const scale = 2;
const canvas = await html2canvas(element, {
scale,
width: element.scrollWidth,
height: element.scrollHeight,
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
useCORS: true,
backgroundColor: '#fff'
});
const pdf = new jsPDF({
orientation: 'portrait',
unit: 'pt',
format: 'a4'
});
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
const margin = 24;
const printWidth = pageWidth - margin * 2;
const printHeight = canvas.height * printWidth / canvas.width;
if (printHeight <= pageHeight - margin * 2) {
pdf.addImage(
canvas.toDataURL('image/png'),
'PNG',
margin,
margin,
printWidth,
printHeight
);
} else {
throw new Error('Content is taller than one page; use the multi-page version.');
}
pdf.save('print.pdf');
}
The proportional equation, canvas.height * printWidth / canvas.width, prevents stretching. Do not independently guess a PDF height: changing it without changing the width changes the aspect ratio and visibly distorts the capture.
Free tools Windows power users keep installed
One-click scans. No signup required.
Split a tall canvas across PDF pages
When the calculated height exceeds the usable page height, shrinking the whole bitmap can make text unreadable. The following version slices the source canvas into page-sized strips. It uses the same page width and margins for every page and preserves the original ratio.
async function printLongCapture() {
const element = document.querySelector('#capture');
if (!element) throw new Error('Missing #capture element');
const scale = 2;
const canvas = await html2canvas(element, {
scale,
width: element.scrollWidth,
height: element.scrollHeight,
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
useCORS: true,
backgroundColor: '#fff'
});
const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' });
const margin = 24;
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
const printWidth = pageWidth - margin * 2;
const usableHeight = pageHeight - margin * 2;
const sourcePixelsPerPoint = canvas.width / printWidth;
const sliceHeight = Math.floor(usableHeight * sourcePixelsPerPoint);
let sourceY = 0;
let pageNumber = 0;
while (sourceY < canvas.height) {
const currentSourceHeight = Math.min(sliceHeight, canvas.height - sourceY);
const slice = document.createElement('canvas');
slice.width = canvas.width;
slice.height = currentSourceHeight;
const context = slice.getContext('2d');
context.drawImage(
canvas,
0, sourceY, canvas.width, currentSourceHeight,
0, 0, canvas.width, currentSourceHeight
);
if (pageNumber > 0) pdf.addPage();
const printHeight = currentSourceHeight / sourcePixelsPerPoint;
pdf.addImage(slice.toDataURL('image/png'), 'PNG', margin, margin, printWidth, printHeight);
sourceY += currentSourceHeight;
pageNumber += 1;
}
pdf.save('print-long.pdf');
}
This approach may cut a line or card at a page boundary because it slices pixels, not semantic DOM blocks. If clean boundaries matter, capture each section separately and add a new page for each section. The jspdf-html2canvas package documents node-list multi-page handling and automatic snapshot fitting, which can be useful when your layout is already divided into sections.
Rank #3
Capture several DOM sections instead of one giant bitmap
For invoices, reports, or dashboards with natural panels, select each panel, render it with the same options, and add it to the PDF in order. Before rendering, wait for fonts, charts, and images to finish loading; otherwise the bitmap faithfully records the incomplete state. A section-based workflow also limits memory use and gives you a place to add page breaks intentionally. Use a consistent scale for all sections, and compute each section's displayed height from its own canvas width and height.
Images, backgrounds, and browser-state issues
Remote images
useCORS: true only helps when the image server supplies the required CORS response header. If it does not, the image may be omitted or the canvas may become unusable. Host the asset on the same origin or retrieve it through a proxy that adds appropriate CORS headers; do not assume the option can bypass browser security.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Fixed and sticky elements
html2canvas clones the document. Fixed-position headers, sticky navigation, and elements affected by scroll can appear repeatedly or at an unexpected offset in a full-page capture. Normalize the scroll position, inspect the cloned layout, and use a capture-specific class or custom CSS to change those elements for printing.
Background color
Set backgroundColor: '#fff' when a white paper background is required. A transparent background is different from a white one: transparency can be useful for compositing, but a PDF viewer or printer may display it differently depending on the surrounding page.
Rank #4
- Are you familiar with html5? Then get this "HTML5 HTML Logo Web Programmer Nerd Funny" featuring HTML logo. Perfect for computer programmer, developer, software developer and technician who does computer programming language, coding and gaming on internet.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Troubleshooting checklist
| Symptom | Likely cause | Fix |
|---|---|---|
| Text or lines look blurry | The bitmap has too few source pixels for the insertion size. | Increase scale moderately, keep the PDF insertion width the same, and watch memory use. |
| Blank or partly rendered canvas | Capture dimensions or scale exceed a browser/device canvas limit. | Reduce scale or dimensions, capture sections, and avoid one unlimited full-document bitmap. Oversize failures may not throw an error. |
| Bottom or right edge is missing | The render used viewport dimensions. | Set width/height and windowWidth/windowHeight from scrollWidth/scrollHeight. |
| Remote photos are absent | The source does not permit cross-origin canvas use. | Use useCORS: true only with a server-provided CORS header, or use a same-origin proxy. |
| White strip or shifted content | Scroll state or fixed-position elements changed in the cloned document. | Normalize scrolling, inspect fixed elements, and apply capture-only CSS. |
| Printed page is stretched | PDF width and height were chosen independently. | Derive the height from canvas.height * printWidth / canvas.width. |
Performance, reliability, and print-quality decisions
- Measure before rendering so you do not repeatedly capture a viewport and discover missing content later.
- Start with a moderate scale, then increase it only if the print result is soft. Every increase raises pixel count and memory pressure.
- Prefer page-sized or section-sized renders for long documents. They reduce the chance of silent canvas failure and avoid shrinking all text to fit one page.
- Keep the source page stable while rendering: finish asynchronous content, avoid animations, and capture after layout has settled.
- Use PNG when crisp UI text and flat colors matter. Choose another image format only when its size or transparency behavior suits your output; the PDF placement math is unchanged.
- Remember that html2canvas reproduces what the browser can access and paint; it is not a print engine. Cross-origin restrictions, browser-only widgets, and unsupported rendering behavior remain possible.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server when you would rather send a URL than maintain browser automation. It can return PNG, JPEG, WebP, or a PDF, and its capture options include full-page output with lazy images loaded, element selection by CSS selector, custom CSS and JavaScript, waiting for a selector, delay, or network idle, device and viewport settings, retina scale, PDF paper size, margins, landscape mode, and page ranges.
Before capture, ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or 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. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
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 reinstallThe free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is available on every plan.
Here is the one-call version; see the ScreenshotNeo API documentation for the complete parameter reference.
Best Value
- Used Book in Good Condition
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}`);
If you need a clean page image without implementing browser setup, try ScreenshotNeo's free sign-up: 1,000 screenshots each month, no card required.
Frequently Asked Questions
Can I change the paper size without changing the html2canvas capture?
Yes. Keep the source canvas unchanged and choose a different jsPDF format or orientation, then recompute the target width and proportional height for that page.
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 →Should I use a higher scale to make a document fit on one page?
No. Scale changes source pixel density, not the physical page layout. Fitting is controlled by the PDF placement dimensions; a taller document should be split or rendered in sections.
Why does a PDF contain a page break in the middle of a card?
A bitmap slice has no knowledge of DOM boundaries. Capture cards or sections individually when page breaks must follow semantic components.
Does html2canvas reproduce a browser's native print CSS exactly?
No. It paints an accessible DOM snapshot into a canvas. Print-specific CSS, cross-origin assets, fixed positioning, and browser-only behavior may require capture-specific adjustments.
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.




