To export everything inside a scrollable element with jsPDF, render the element with pdf.html() and expand the scroll container in html2canvas’s cloned document. A scroll position only determines what is currently in view; it does not make the rest of a nested scroll area part of the rendered layout. Adjusting the clone lets the export expose the full content without changing the live page.
Why a PDF may contain only the visible part
jsPDF’s html() workflow uses html2canvas to render DOM content. It creates a temporary container for the source and uses element dimensions such as clientHeight, scrollHeight, and offsetHeight when setting up that render. But a nested element styled with overflow: auto or overflow: hidden can still clip its children. The relevant fix is usually to change the cloned scroll container’s layout before the renderer takes its image—not simply to change the browser’s scroll position.
The example below targets one element, changes overflow and height only in the cloned document, and leaves the interactive page alone. Its selectors and the layout changes may need adaptation to your own DOM.
Install and check the required dependencies
Install jsPDF using the package manager and version policy already used by your application. The html() method has an optional html2canvas dependency. DOMPurify is also used when passing an HTML string; prefer passing a DOM element when practical, and never pass unsanitized user-controlled HTML to jsPDF.
#1 Best Overall
- Convert your PDF files into Word, Excel & Co. the easy way
- Convert scanned documents thanks to our new 2022 OCR technology
- Adjustable conversion settings
- No subscription! Lifetime license!
- Compatible with Windows 11, 10, 8.1, 7 - Internet connection required
npm install jspdf html2canvas
Check which versions your application actually resolves, and verify option behavior against that pinned jsPDF release. Upstream source and declarations on a moving branch can change, so do not treat an unpinned branch as a compatibility guarantee.
Measure the scroll container before exporting
Query the element whose content you want, rather than the whole document by default. Inspect its dimensions and those of any nested scrollable children. A difference between scrollHeight and clientHeight is a useful indication that content extends beyond the visible box, but also inspect ancestor elements: an ancestor can be the actual clipping scrollport.
const target = document.querySelector('#report');
if (!target) throw new Error('Export target #report was not found');
console.table({
clientHeight: target.clientHeight,
scrollHeight: target.scrollHeight,
offsetHeight: target.offsetHeight,
overflowY: getComputedStyle(target).overflowY
});
If a child owns the scrollbar, expand that child in the clone. If several nested elements clip content, identify which ones must be expanded for the intended export; removing every overflow rule indiscriminately can change layout or reveal content that should not be included.
Rank #2
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
Capture the full scrollable content with jsPDF
This browser-side example waits for document images to settle, then calls pdf.html(). In onclone, it changes the copied #report element to expose all its content. The live element is not modified. Add equivalent clone-side changes for nested scroll containers in your markup.
Free tools Windows power users keep installed
One-click scans. No signup required.
import { jsPDF } from 'jspdf';
function waitForImages(root) {
const images = [...root.querySelectorAll('img')];
return Promise.all(images.map((img) => {
if (img.complete) return Promise.resolve();
return new Promise((resolve) => {
img.addEventListener('load', resolve, { once: true });
img.addEventListener('error', resolve, { once: true });
});
}));
}
async function exportReport() {
const target = document.querySelector('#report');
if (!target) throw new Error('Export target #report was not found');
await document.fonts.ready;
await waitForImages(target);
const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' });
await pdf.html(target, {
margin: [36, 36, 36, 36],
autoPaging: 'text',
html2canvas: {
scale: 1,
onclone: (clonedDocument) => {
const clonedTarget = clonedDocument.querySelector('#report');
if (!clonedTarget) return;
clonedTarget.style.height = 'auto';
clonedTarget.style.maxHeight = 'none';
clonedTarget.style.overflow = 'visible';
// If a descendant owns the scrollport, expand that specific element too.
clonedTarget.querySelectorAll('.report-scroll').forEach((element) => {
element.style.height = 'auto';
element.style.maxHeight = 'none';
element.style.overflow = 'visible';
});
}
}
});
pdf.save('report.pdf');
}
exportReport().catch(console.error);
Replace #report and .report-scroll with selectors from your page. If the content is rendered asynchronously, wait for the application’s own data-loading or rendering completion signal before calling exportReport(); an image wait alone cannot guarantee that charts, embedded content, or later DOM updates are ready.
Choose the right dimensions and pagination behavior
Expand content, not just the rendering viewport
html2canvas.windowWidth and windowHeight control the rendering viewport dimensions. Use them when the renderer’s viewport is too small or yields a different responsive layout than intended. They do not necessarily expand a nested child’s own clipped content box; that is why clone-side height and overflow changes matter.
Rank #3
- EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
- READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
- CREATE, COMBINE, SCAN and COMPRESS PDFs
- FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
- LIFETIME License for 1 Windows PC or Laptop. 5GB MobiDrive Cloud Storage Included.
Be deliberate with width. A wider rendering viewport can cross a CSS media-query breakpoint, changing columns, font sizes, or line wrapping. That may make the PDF different from the screen view you meant to preserve. Set the viewport to the width appropriate for the desired output and inspect the result rather than increasing it blindly.
Use scroll coordinates for positioning
scrollX and scrollY control the rendering scroll coordinates and can matter for fixed-position elements. They are not a substitute for expanding a nested scroll container. If a fixed toolbar appears in an awkward position or is duplicated across pages, decide whether it belongs in the export and adjust the cloned document accordingly.
Review page breaks and long-page tradeoffs
autoPaging is a separate PDF-layout choice. It does not unclip hidden DOM content. Review the page count, text wrapping, and boundaries after expanding the element. Content that should remain together may need export-specific styling or deliberate manual page construction; a single automatic layout is not guaranteed to keep every group intact.
Rank #4
- Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.
- Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
- Read & Annotate. Enjoy intuitive reading modes and powerful tools to comment, highlight, and mark up PDFs.
- Create & Manage PDFs. Create new PDFs, combine multiple files, scan documents, and compress for easy sharing.
- Fill & Sign Forms. Complete forms and digitally sign documents with secure e-signature tools.
Choose between clone expansion and an export layout
| Approach | Best fit | Tradeoff |
|---|---|---|
| Expand the cloned scroll container | You want the current element’s content and styling, with the interactive page left unchanged. | Requires selectors that match the cloned DOM and CSS changes appropriate to the actual nesting. |
| Use a dedicated export wrapper | The screen layout is highly interactive or clipped, while the PDF needs a predictable document layout. | You must maintain export-specific markup or styles alongside the screen version. |
| Build pages manually | Page boundaries, grouping, or pagination need more control than automatic HTML rendering provides. | More implementation work; you take responsibility for measuring and placing content. |
For faithful capture of the current content, clone expansion is a sensible first try. For a polished report with controlled page breaks, an export wrapper often gives clearer control over line wrapping, fixed or sticky UI, and page layout.
Images, fonts, security, and reliability
- Images: Wait for images and fonts before rendering. For images hosted on another origin, html2canvas’s
useCORSandproxyoptions may be relevant. CORS restrictions can prevent a remote image from appearing; confirm that the image host permits the required access or use an appropriate proxy. - Fonts: Waiting for
document.fonts.readycan reduce layout changes caused by late font loading. Check the PDF for fallback fonts and altered line breaks. - Dynamic content: Ensure the element is populated before capture. A chart canvas, virtualized list, iframe, or component that renders after a network response may need application-specific preparation.
- Sanitization: Sanitize user input passed to jsPDF. If you pass an HTML string rather than an element, account for the DOMPurify dependency noted by jsPDF’s README.
- Very long content: A taller render can consume substantial browser memory and take longer. Test with representative content, and consider an export-specific layout or manual page generation if a single capture becomes impractical.
Test the generated PDF in the browsers your product supports. Compare the first and last content in the PDF with the target element, check for missing images, and review page count and page boundaries. These are runtime checks for your page and browser; there is no universal dimension or page-count threshold that guarantees a correct export.
Troubleshoot common failures
| Symptom | Likely cause | What to change |
|---|---|---|
| PDF shows only the visible portion | A nested scroll container remains clipped in the cloned document. | Find the element whose overflow clips the content; set its cloned height or max-height to auto and overflow to visible. |
| PDF still has the wrong layout | The rendering viewport triggers different responsive CSS, or the wrong element was selected. | Verify the target selector and tune windowWidth and windowHeight to the intended layout. Check media-query breakpoints. |
| Images are missing | Images were not loaded in time, or cross-origin restrictions prevent drawing them. | Wait for image completion; configure useCORS or a suitable proxy where appropriate, and verify the host’s CORS behavior. |
| Text wraps or pages break unexpectedly | Fonts, viewport width, pagination, or export CSS differs from the intended layout. | Wait for fonts, inspect page width and autoPaging, then consider a dedicated export wrapper or manual page layout. |
| Fixed controls appear in the wrong place | Rendering scroll coordinates and fixed positioning affect the clone. | Use scrollX or scrollY for coordinate control as needed; hide irrelevant controls in the clone. |
| The export is blank or incomplete | The target was missing, not yet rendered, or the html2canvas dependency/configuration is unresolved. | Check the selector, wait for app content, and confirm the versions and optional-dependency setup resolved by your build. |
Or skip the browser setup
If the page you need is publicly reachable by URL, ScreenshotNeo can return a screenshot or PDF from one GET request. It is not a replacement for exporting a local, unsaved, authenticated DOM element: use the jsPDF method above for that case. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. See the ScreenshotNeo API documentation.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Visit ScreenshotNeo to see the service, or sign up for 1,000 free screenshots a month with no card.
Frequently Asked Questions
Does changing scrollY capture the rest of a nested scroll area?
No. It changes the rendering scroll coordinate; expand the nested scroll container in the cloned document to expose its hidden content.
Best Value
- ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
- MAXIMUM FUNCIONALITY – create interactive forms, compare PDFs, bates numbering, find and replace text or colors, convert documents, OCR engine, comment, highlight, fill out and print forms, document protection and others
- EASY TO INSTALL AND USE – well-structured user-interface, in-program instructions, free tech support whenever you need it
- GREAT VALUE FOR MONEY - why spend a fortune if you can have maximum functionality at a reasonable price - this also fits the requirements of companies very well
Will clone-side CSS changes alter the live page?
The onclone callback edits the cloned document used for rendering, so the original interactive page can remain unchanged.
Can ScreenshotNeo export an element from my local app?
No. It captures a page reachable by URL; a local or authenticated DOM element that is not publicly reachable should be exported in the browser with jsPDF.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesQuick 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.




