svg2pdf.js icon indicating copy to clipboard operation
svg2pdf.js copied to clipboard

Unsupported features/Known issues

Open HackbrettXXX opened this issue 5 years ago • 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

HackbrettXXX avatar May 06 '19 10:05 HackbrettXXX

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.

bernhardreiter avatar Jul 01 '19 09:07 bernhardreiter

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.

HackbrettXXX avatar Jul 01 '19 10:07 HackbrettXXX

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

eliaschaflo avatar Jan 16 '20 13:01 eliaschaflo

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?

HackbrettXXX avatar Jan 16 '20 15:01 HackbrettXXX

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!

eliaschaflo avatar Jan 16 '20 16:01 eliaschaflo

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).

HackbrettXXX avatar Jan 16 '20 16:01 HackbrettXXX

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?

eliaschaflo avatar Jan 21 '20 13:01 eliaschaflo

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

eliaschaflo avatar Jan 21 '20 14:01 eliaschaflo

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).

HackbrettXXX avatar Jan 21 '20 14:01 HackbrettXXX

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

HackbrettXXX avatar Jul 17 '20 13:07 HackbrettXXX

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

xurenda avatar Nov 09 '21 08:11 xurenda

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.

HackbrettXXX avatar Nov 10 '21 09:11 HackbrettXXX

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

vitornvpaixao avatar Dec 02 '21 21:12 vitornvpaixao

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

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

yGuy avatar Dec 03 '21 08:12 yGuy

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.

vitornvpaixao avatar Dec 03 '21 14:12 vitornvpaixao

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.

HackbrettXXX avatar Dec 03 '21 14:12 HackbrettXXX

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.

vitornvpaixao avatar Dec 06 '21 17:12 vitornvpaixao

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

xurenda avatar Dec 23 '21 08:12 xurenda

@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 avatar Dec 23 '21 09:12 HackbrettXXX

@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.😄

xurenda avatar Dec 23 '21 09:12 xurenda

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

iziorama avatar Jun 05 '22 19:06 iziorama

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

eriese avatar Jul 22 '22 23:07 eriese