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

Object filling by pattern causes an error in Adobe Acrobat #83

Closed AletisFirst closed 5 years ago

AletisFirst commented 5 years ago

Browser's Print Preview:

Снимок экрана 2019-05-13 в 17 08 47

Adobe Acrobat, Adobe Acrobat Pro:

Снимок экрана 2019-05-13 в 17 09 52
HackbrettXXX commented 5 years ago

Thanks for the bug report. Can you please provide a minimal repro SVG?

AletisFirst commented 5 years ago

This code based on svg.js v2.7. As an example. The rectangle will also disappear in Adobe Acrobat. `
let draw = SVG('canvas')

let hatch = draw.pattern(4, 4, function (add) { add.rect(4, 4) .attr({'fill': '#ffffff'}); add.path('M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2') .attr({'stroke-width': .6, 'stroke': '#a5a5a5'}) });

let rect = draw.rect(50, 50).stroke('#000').fill(hatch) `

HackbrettXXX commented 5 years ago

So the actual svg is:

<svg id="SvgjsSvg1006" width="100%" height="100%"
     xmlns="http://www.w3.org/2000/svg" version="1.1"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:svgjs="http://svgjs.com/svgjs">
  <defs id="SvgjsDefs1007">
    <pattern id="SvgjsPattern1008" x="0" y="0" width="4" height="4" patternUnits="userSpaceOnUse">
      <rect id="SvgjsRect1009" width="4" height="4" fill="#ffffff"></rect>
      <path id="SvgjsPath1010" d="M-1 1L1 -1M0 4L4 0M3 5L5 3 " stroke="#a5a5a5" stroke-width="0.6"></path>
    </pattern>
  </defs>
  <rect id="SvgjsRect1011" width="50" height="50" stroke="#000000" fill="url(#SvgjsPattern1008)"></rect>
</svg>

I cannot reproduce the bug. For me it renders fine both in Chrome as well as Adobe Acrobat Reader. Which version of svg2pdf, jsPDF and Acrobat are you using?

AletisFirst commented 5 years ago

svg2pdf - v.1.3.4, jsPDF - v.2.0.2 Arcobat Pro - v.11.0.23.22 (Мас)

HackbrettXXX commented 5 years ago

Please correct me if I'm wrong but it seems that your Acrobat version is quite outdated. Could you test your pdf on a more recent version?

Could you also try and open this file, which I created from the above SVG: pattern.pdf

AletisFirst commented 5 years ago

Sorry for taking you time, the error is caused by the following code: pdf.output('datauri') pdf.save('file.pdf');