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

Cannot convert an image/svg+xml object using patterns #131

Closed iggdrael closed 4 years ago

iggdrael commented 4 years ago

Describe the bug A clear and concise description of what the bug is. What version are you using (exact version of svg2pdf.js and jspdf - the yWorks fork version, of course)?

To Reproduce Steps to reproduce the behavior:

  1. With the following SVG and JavaScript code
  2. I get this result
  3. Or see this error

Expected behavior I would have expected the PDF to look like so. This is in accordance to the following SVG spec

Screenshots If applicable, add screenshots, SVGs, and PDFs to explain the problem

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

HackbrettXXX commented 4 years ago

Please provide sample code or a sample SVG file so we can reproduce the error.

iggdrael commented 4 years ago

Please provide sample code or a sample SVG file so we can reproduce the error.

g4075 ---> style="fill:#ffffff;fill-opacity:0.99549549;stroke:#ff0000;stroke-width:1.00038028;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:url(#tartan);"

I think the error comes from "fill:url(#tartan);" because it can't access to the pattern.

object id="vetement" type="image/svg+xml" data="vetement.svg"</object

function svgtopdf(){
var mySVG = document.getElementById("vetement"); const svgDoc = mySVG.contentDocument; const svgElement = svgDoc.getElementById("g4075"); //The object i want to convert

var margin = 0;
var width = 300;//svgElement.width.baseVal.value + 2 * margin;
var height = 300;//svgElement.height.baseVal.value + 2 * margin;

const pdf = new jsPDF('l', 'mm', [width, height]);
svg2pdf(svgElement, pdf, {xOffset: 0,yOffset: 0,scale: 1});
pdf.save('test.pdf');

}

yGuy commented 4 years ago

Other github repos have a label for "good issue reports". This one would require a label "worst issue report ever".

You really need to work on this if you don't want to get banned. Because even if there was someone who could help you with this, the way you reported it, I really don't see how anybody would want to help you.

Please edit the issue and your comments. Fill in the template, adjust the description. Everything.