Use Cases

Performance Engineering

Understand vue-pdf-export large-document performance engineering, incremental Canvas rendering, memory reduction, cancellation, cleanup and regression testing.

The large-document milestone was not only a benchmark exercise. It changed the runtime architecture and added repeatable correctness, cleanup and memory diagnostics.

The measurements below are historical fixtures. The latest full browser and stress reruns were not part of this docs update; measure your own document on target devices.

Rendering architecture

The package dynamically loads PDF engines and the optional composition engine, resolves a shared template once, reuses unchanged header/footer and styled slot captures, reduces repeated image waiting, and prunes unrelated app DOM while capturing a layer. Oversized splittable Canvas sections are preflight paginated on private DOM, then fitting fragments are reused. Cooperative yields avoid waiting for hidden-tab animation frames. Generation reuses one final Blob for preview and download, with cleanup, cancellation and opt-in timing metrics.

A local nine-page Canvas/slot export with watermark off was inspected: 27 image objects and zero PDF text-showing commands; a separate text-mode PDF contained 423 text commands. One local Canvas slot session changed from 26.89 seconds to 12.55 seconds after the refinements, without a controlled benchmark. A separate nine-page text run was about 4.35 seconds; no text-mode speedup was established. These observations do not predict your document's runtime or fidelity. Record browser/device, page count, renderer, assets, quality and cold/warm state when comparing exports.

Executive outcome

  • paginated Canvas documents can render page by page instead of one giant document-height canvas
  • 50-page and 100-page Canvas exports are verified as real, non-empty PDFs on the incremental path
  • static HTML footer content is rasterized once and reused across pages
  • selectable-text mode caches repeated image sources within one generation
  • long work can be cancelled and then safely regenerated
  • progress can expose stage, progress, currentPage and totalPages
  • temporary DOM, Canvas backing stores and encoded image references are released earlier
  • browser yielding was added between expensive chunks
  • encrypted raster memory retention was isolated and reproduced directly in jsPDF

Phase map

PhaseFocusResult
Phase 1Benchmark/stress foundationActual page count, Blob size, Canvas geometry, timing, memory and progress telemetry.
Phase 2.1Static HTML footer bottleneckRender once + reuse; major time, output-size and heap reductions in the fixture.
Phase 2.2Clean memory isolationFresh-context methodology separated temporary peaks from retained heap.
Phase 2.3ASecurity isolationBasic user-password encryption identified as the trigger for high raster retention.
Phase 2.3BLarge-PDF correctnessPage count alone was proven insufficient; Blob size and Canvas telemetry were added.
Phase 2.4Scaling and cliff diagnosticsRaster payload + jsPDF encryption pattern isolated; legacy long-canvas failure instrumented.
Phase 3.1Incremental CanvasPage-bounded captures replaced the giant capture for paginated Canvas documents.
Phase 3.2Security re-testGiant-canvas issue addressed; encrypted-raster retention remained dependency-level.
Phase 3.2.1Raw jsPDF reproductionStrongest retention pattern reproduced without Vue component lifecycle.
Phase 3.3Cancellation + progressCooperative cancellation, recovery and current-page progress added.
Phase 3.4Repeated assets + cleanupPer-generation image cache and shorter DOM/Canvas lifetimes.
Phase 3.5Routing regression hardeningCorrect incremental Canvas branch restored and protected by 50/100-page E2E tests.

Headline measured results

MetricBeforeAfterImprovement
HTML footer, no logo7.82 s1.43 s~81.7% less time / 5.47× faster
HTML footer + logo11.81 s1.29 s~89.1% less time / 9.16× faster
Footer-heavy PDF~46.7 MB~1.0 MB~97.9% smaller
No-logo peak heap102.6 MB26.5 MB~74.2% lower
Giant Canvas capture geometry~99.96M px~1.74M px/page~98.26% lower peak capture area

These percentages describe specific benchmark fixtures or capture geometry; they are not universal whole-package speed or memory guarantees.

Current incremental Canvas correctness

Requested pagesActual pagesTimePDF sizeLargest encoded Canvas
10101.53 s1.5 MB1191 × 1461
25254.33 s3.9 MB1191 × 1461
40407.54 s6.2 MB1191 × 1461
50509.68 s7.8 MB1191 × 1461
606012.56 s9.3 MB1191 × 1461
757516.87 s11.7 MB1191 × 1461
10010025.25 s15.8 MB1191 × 1461

The maximum encoded Canvas remained page-sized as the requested page count increased.

Encrypted raster PDFs

The strongest high-retention behavior was reproduced with raw jsPDF, so the project documents it as memory retention rather than mislabeling it as a permanent Vue memory leak.

Upstream issue: jsPDF #4017 - encrypted raster PDF memory retention

For large text-heavy secured documents whose CSS is supported by the vector renderer, selectable-text mode can be much lighter than raster Canvas mode. This is workload-dependent, not a universal renderer benchmark.

Verification mindset

Large exports are checked with more than “the Promise resolved”: actual page count, Blob size, Canvas dimensions, cancellation/recovery and cleanup signals are part of the regression strategy.

Read the complete phase-by-phase engineering report.

Copyright © 2026