yWorks/svg2pdf.js

Embed images with SVG

Opened this issue · 0 comments

Describe the bug
tags with an href pointing to a SVG file are not displayed correctly

What version are you using (exact version of and jspdf)?
- jspdf: 2.5.1
- svg2pdf.js: 2.2.3

To Reproduce

  1. Test SVG:
<svg
      width="128"
      height="64"
      version="1.1"
      xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      style="user-select: none"
    >
      <rect x="0" y="0" width="128" height="64" stroke="black" fill="none" />
      <image
        width="64"
        height="64"
        x="0"
        y="0"
        href="https://upload.wikimedia.org/wikipedia/commons/1/16/Cellular_phone.svg"
      />
      <image
        width="64"
        height="64"
        x="64"
        y="0"
        href="https://upload.wikimedia.org/wikipedia/commons/a/a0/Goldfish-47022_1280.png"
      />
</svg>

Code:

import { jsPDF } from "jspdf";
import "svg2pdf.js";
const svg = document.querySelector("svg");
const doc = new jsPDF({ format: "a4", unit: "pt" });
doc.svg(svg, { x: 0, y: 0, width: 128, height: 64 }).then((doc) => {
  doc.save("doc.pdf");
});
  1. I get a square with the PNG image but not the SVG

Example Sandbox

Expected behavior
The SVG image should be drawn

Screenshots
Input SVG:
Screenshot from 2024-05-16 15-27-24
Output PDF:
Screenshot from 2024-05-16 15-27-08

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser Chromium
  • Version 125.0.6422.26