You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ecedc6a
Browse filesBrowse the repository at this point in the historyBrowse files
Preserve partially clipped SVG images as vectors in PDF
Rectangular overflow clipping rasterized SVG image elements even when a PDF writer could apply the clip to their vector paths. Small icons then appeared pixelated when zoomed.
Add the opt-in vectorizeClippedSvgImages extraction option. Intersect the image viewport with the overflow rectangle and attach the clip to the converted paths. Preserve the existing raster fallback for rounded clips, compositing effects, and source crops.
Cover enclosed, partially clipped, and rounded SVG images in Chromium and Firefox. Verify that all 83 chain icons in the FA13 PDF export remain vector geometry, including the 76 that previously rendered as 14 by 14 pixel bitmaps.
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,6 +226,7 @@ Main entry point. Traverses the DOM tree under `root`, builds a stacking context
226
226
|`zoom`|`number`|`1`| Scale factor applied to all extracted coordinates. Useful when the source DOM is rendered at a different zoom level |
227
227
|`imageScale`|`number`|`1`| Scale factor for rasterizing embedded images. Higher values (e.g. `2`) produce sharper images when zooming in on the exported file. Max pixel dimension is capped at 4096 |
228
228
|`svgToVector`|`boolean`|`false`| When true, embedded SVG images (in `<img>` tags and CSS `background-image`) are always converted to vector IR nodes (polygon, polyline, text) instead of being rasterized to bitmap image nodes. This produces resolution-independent output but may not accurately render SVGs that use fill-rule:evenodd with complex multi-subpath paths. |
229
+
|`vectorizeClippedSvgImages`|`boolean`|`false`| Preserves SVG `<img>` geometry when an axis-aligned rectangular overflow clip partially covers the image in the normal scroll viewport. Enable for writers that honor rectangular vector clips, such as PDFWriter. |
229
230
|`convertFormControls`|`boolean`|`false`| When true, native form controls are converted into synthetic IR nodes that preserve visible values and states across writers. Supported controls include checkbox, radio, range, file, text-like inputs (including date/time variants), textarea, select, progress, and meter. |
230
231
|`includePseudoElements`|`boolean`|`true`| When true, `::before` and `::after` pseudo-elements with generated content are extracted into the IR as polygon and text nodes. Be careful, this option modifies original DOM cause it need to create real elements for them in DOM. CSS `counter()`, `counters()`, `attr()`, `open-quote`/`close-quote`, and string literals are resolved. Best results with Firefox (native `getBoxQuads` on pseudo replacement elements). |
231
232
@@ -708,7 +709,7 @@ import {
708
709
Enable with `includeImages: true`. All image preloading and embedding is now **automatic** and handled internally by `extractIR` (no need to call any preload function). For custom pipelines, the async image helpers can also fetch/decode what they need on demand; `preloadImages()` is only an optimization. The DOM is **not mutated** during preloading.
709
710
710
711
-**All images** (including `<img>` and CSS `background-image: url()`, even in Shadow DOM) are embedded as data URLs in all output formats (DXF, PDF, PNG, SVG, HTML).
711
-
-**SVG images** (`data:image/svg+xml`, `.svg` URLs): automatically converted to vector geometry (polygons, polylines, text) — no rasterization.
712
+
-**SVG images** (`data:image/svg+xml`, `.svg` URLs): converted to vector geometry when the image needs no raster effects or cropping. An enclosing rectangular overflow clip preserves the vector output. The `vectorizeClippedSvgImages` option also preserves vector `<img>` content under partial rectangular clipping for PDF.
712
713
-**Raster images** (PNG, JPEG, GIF, WebP, data URLs, remote URLs): extracted as `image` IR nodes with embedded data URL.
713
714
-**Video elements**: enable with `includeVideos: true` to rasterize each `<video>` into an `image` IR node using its first decoded frame. `imageScale` also applies to video frame rasterization.
714
715
-**CSS `background-image: url()`**: SVG URLs are vector-converted; raster URLs are extracted as image nodes.
Copy file name to clipboardExpand all lines: memories/htmlConverter-image-extractor-notes.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@
13
13
- Low-level image helpers (`extractImageGeometry`, `extractBackgroundImage`, and the masked-image path) are now async and must not depend on `preloadImages()` for correctness; direct custom-pipeline calls should work on remote SVG/CSS image URLs without an explicit preload step.
14
14
- Page-side remote image preloads should not use `credentials: "include"`; cross-origin SVG/image fetches in the browser context need default/same-origin credentials or ACAO `*` routes start failing and remote SVG fallback tests regress.
15
15
- Asset waits must be bounded: image decode/fetch and video readiness can otherwise stall extraction indefinitely on ad-heavy pages. Prefer timeouts that skip the bad asset over waiting forever.
16
+
- For PDF, `vectorizeClippedSvgImages` preserves eligible SVG image paths by intersecting the rectangular overflow clip with the image viewport. Keep it opt-in for writers that support clips on vector geometry.
16
17
17
18
18
19
- Pixelated or tiny raster CSS background images need two protections in `renderBackgroundImage()`: disable canvas smoothing for the draw, and keep the output as PNG instead of JPEG. Nearest-neighbor drawing alone is not enough because JPEG re-encoding reintroduces blur at hard pixel edges.
0 commit comments