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
667 stars 104 forks source link

Markers on lines and paths are not rendered in PDF #30

Closed stefano-caporale-wk closed 7 years ago

stefano-caporale-wk commented 7 years ago

I used the following SVG as a test but the markers are not rendered in PDF.

<svg id="svg" width="400" height="400">
        <defs>
            <marker id="triangle-end" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="10" markerHeight="10" orient="auto">
                <path d="M 0 0 L 10 5 L 0 10 z" fill="#FF0000"></path>
            </marker>
            <marker id="circle-start" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="10" markerHeight="10" orient="auto">
                <circle r="5" cx="5" cy="5" fill="#FF0000"></path>
            </marker>
        </defs>
        <line x1="100" y1="100" x2="200" y2="200" marker-end="url(#triangle-end)" marker-start="url(#circle-start)" stroke="#000000"></line>
    </svg>
HackbrettXXX commented 7 years ago

The reason is that markers are currently supported for paths only. The workaround would be to replace the line element with a path element: <path d="M 100 100 L 200 200" marker-end="url(#triangle-end)" marker-start="url(#circle-start)" stroke="#000000"></path>

stefano-caporale-wk commented 7 years ago

Thank you @HackbrettXXX . My bad on not doing a good check on paths. I'm closing the issue.

yGuy commented 7 years ago

Since this is a possible improvement that we can add to the library and for documenting the current state, I am reopening this so that we can track it.

HackbrettXXX commented 7 years ago

@stefano-caporale-wk we added marker support for line and polygon elements. This feature will come with the next release.