yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
654 stars 100 forks source link

alignment-baseline attribute does not work #109

Closed Fadiabb closed 3 years ago

Fadiabb commented 5 years ago

The attribute alignment-baseline has no effect on the generated pdf.

svg2pdf.js version: 1.4.0 ywork-jspdf version: 2.1.0

To Reproduce

<html>
  <head>
    <script src="../node_modules/jspdf-yworks/dist/jspdf.min.js"></script>
    <script src="../node_modules/svg2pdf.js/dist/svg2pdf.min.js"></script>
  </head>
  <body>
    <script type="text/javascript">
      function downloadpdf() {
        const pdf = new jsPDF("l", "mm", "a3");
        let svg = document.getElementById("svg").firstElementChild;
        svg2pdf(svg, pdf, 0.2);
        pdf.save();
      }
    </script>
    <div id="svg">
        <svg>
            <path
            d="M60,10 L60,110 
            M30,10 L300,10 
            M30,65 L300,65 
            M30,110 L300,110
            "
            stroke="grey"
            />
            <text alignment-baseline="hanging" x="60" y="10">A hanging</text>
            <text alignment-baseline="middle" x="60" y="65">A middle</text>
            <text alignment-baseline="baseline" x="60" y="110">A baseline</text>
        </svg>
    </div>
    <button type="button" onclick="downloadpdf()">download pdf</button>
  </body>
</html>

What we have in Browser: alignment-baseline

The generate pdf: alignment-baseline-pdf

yGuy commented 5 years ago

See also #80

yGuy commented 5 years ago

Thanks for the perfect test-case!