alafr / SVG-to-PDFKit

Insert SVG into a PDF document created with PDFKit
MIT License
397 stars 111 forks source link

Inline Clip-Path Specifications Ignored - Incorrect PDF Rendering #181

Open Ganesh-AT opened 9 months ago

Ganesh-AT commented 9 months ago

Reproducible with the top of trunk code as of Dec 1, 2023

Example SVG Code:

``` svg CLK_NP CLK_P ```

Rendering on demo page:

image

Rendering with Chromium engine (Edge) (left) and Firefox (right):

image

Ganesh-AT commented 9 months ago

After spending some time debugging through the Chrome Dev Tools, I figured out that the issue is related to some call to resolveUrl within the source code.

For testing, I re-framed the clip path polygon as a defs entry and referenced it with the url scheme. The generated PDF seems to be OK after I made the change as below:

Raw SVG after re-framing offending clip path as a defs entry:

``` svg CLK_P ```

I am hoping there is someone out here who is familiar with the code base / control flow, and can propose a fix for inline clip-path specifications.