Signature_pad: crop toDataURL('image/svg+xml');

Created on 7 Feb 2017  ·  5Comments  ·  Source: szimek/signature_pad

hi. while ive read posts on how to crop canvas, its output is base 64 png. and yes, not everyone has access to the server so doing the trimming client side would definitely be helpful.

would like to request to have a crop for base 64 svg. svg is still best for output because it is vector.

enhancement

All 5 comments

bump. this is a very useful feature. ^_^

i hope this feature gets some interest

Three years in and not even a reply. Bump

Three years in and not even a reply. Bump

Alright this made me emotional and want to close this issue once and for all . Will be back with solution. happy Coding.

PRs are welcome, though if this cropping code could be implemented as a separate library or as a separate function that can doesn't have to imported if it's not used, that would be preferable to avoid bloating this library with features few people need.

Also, I'm not really maintaining this library anymore. I'll try to clean up a few things soon and update the README file with information that I'm looking for a maintainer.

I am sorry that I sounded offensive. I did not intend to offend anyone. Thank you for this package, I am happily using it. What I do not like on my search for specific answers is browsing through old and open tickets that did not receive any response, so perhaps I overlooked szimeks apparent response, that he took it up as an enhancement. Again, thank you for for this package.

To anyone desperately looking up ways for cropping SVG, I found out about multiple solutions.

  1. I got lucky, because I am using those signatures in fabric.js, where you can import SVG in a way that it trims the white-space automatically. See this code snippet:
fabric.loadSVGFromURL(svgFilePath, () => {
  // these are your signature path elements grouped together 
    var loadedObjects = new fabric.Group(group);
  },
  function (item, object) {
    object.set("id", item.getAttribute("id"));
    group.push(object);
  }
);

2, You can modify the viewBox property in your SVG xml code to only show the signature.

  1. Otherwise, if the background is blank, you could simply omit trimming any whitespace and work with the full vector-"image" of your signature. In another problem, where I include the SVG in a PDF-file, I went this way.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

derUli picture derUli  ·  3Comments

crazzeto picture crazzeto  ·  8Comments

Zuldra picture Zuldra  ·  4Comments

erangaapp picture erangaapp  ·  8Comments

MarcGodard picture MarcGodard  ·  8Comments