yWorks/svg2pdf.js

Unsupported features/Known issues

HackbrettXXX opened this issue · 22 comments

Here is a list of known issues/unsupported features.

  • foreignObject support
  • transforms on elements other than path within clipPath
  • textPath attribute
  • text stroking
  • textLength attribute
  • glyph elements
  • mask and filter elements
  • animations
  • most units other than px
  • different opacities on gradient stops

To me it would make sense to put the feature "Images with urls that are not inline data urls" in an issue
on its own. There is the jsPDF.addImage() module which could be looked at for the functionality.

The addImage plugin also basically only supports data urls. I just saw that the original jsPDF made some changes to support other urls via synchronous requests. Synchronous requests are deprecated and should usually not be used, though. As far as I can see there is also no option to preload images. So we can support non-data-urls only when we make the API of svg2pdf asynchronous. This should be done together with a 2.0 release.

I tried rounded corner rects (rx attribute), but the pdf export ignore this attribute.

As far as I know, the rx/ry attributes are fully supported. Are you sure your SVG is correct? Could you give us a snippet of your SVG?

Yes you are right! This was showing good in the browser but not in the pdf
<rect width="60" height="60" rx="15" />
I had to add ry value and now works perfectly fine.
<rect width="60" height="60" rx="15" ry="15"/>
Thanks por pointing that it is supported!

Actually, your SVG is right. MDN states

If a properly specified value is provided for rx but not for ry (or the opposite), then the browser will consider the missing value equal to the defined one.

So omitting one of the values is correct. We should fix this (#126).

Hi again. Wanted to know if the text style attribute 'font-weight' is implemented.
I am using it and the svg shows correctly but the pdf looks 'regular' everywhere. Is there something I am doing wrong?

Interesting! It works by using 'bold', 'normal' but not with numeric value. Anyway, would like to add a 'light' type with the existing fonts.

Yes. This is mainly because jsPDF only supports 'normal', 'bold', etc.. With custom fonts and some tricking, we might be able to support other font styles, though. When adding a font to jsPDF, you can also specify the font-style, which in theory, could also be a numeric value. Needs to be tested though.
Also, svg2pdf needs to support numeric values. Created a new issue (#128).

Ah, accidentally copied the wrong issue number in #140.

Unfortunately does not support filter elements, my svg has Gaussian blur and shadows, is there any way to work properly in pdf again?

AFAIK, PDF has no native feature like SVG filters. A workaround might be to replace all elements with filters in the SVG with <image>s of the rendered element.

Hi, there is any way to add multiple svgs instead one?

yGuy commented

Hi, there is any way to add multiple svgs instead one?

Sure, just make more calls to doc.svg(...)

Hi @yGuy, thanks for your quick answer. I already tried but with more than one is not rendered in pdf.
This pdf has only one page with a canvas image, and i'm trying to add multiple svg (with paths) layers above this image.

Did you confirm the SVGs are in fact not there? Are they maybe just occluding each other? Please check if maybe something else is going wrong... maybe not all calls to doc.svg() are actually called? If you think this is an issue of svg2pdf, please provide a runnable example, so we can reproduce the issue.

Hi @HackbrettXXX, i will analyse what might be going through and if necessary i will open an issue with a runnable example. Thanks boths for your help.

Hi, please tell me why mask is not supported. As far as I know, pdf should support masking.

@xurenda You are right, PDF supports masking and it would probably be possible to add support for the feature. It just hasn't been implemented so far, because it's used rather rarely. We would happily merge and assist with a pull request, though. Although we need to add the masking feature to jsPDF, as well, first.

@HackbrettXXX Okay, thank you for your reply, I need the mask very much, but I am not good enough, I hope someone can solve it.😄

HI! Did you have a plan to support CMYK colors as jsPDF supports it?
Maybe using custom property like device-cmyk=""

I'd be very grateful for support for transform-origin!