是否可以将SVG转换为p:signature使用的字符串? [英] Is it possible to convert a SVG to a string p:signature uses?

查看:107
本文介绍了是否可以将SVG转换为p:signature使用的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从其他应用程序获取SVG签名,并希望将其保存为字符串值,以便我们可以在当前应用程序上使用PrimeFaces签名.

I'm and getting an SVG signature from a different application and want to save it as a string value so we can use PrimeFaces signature on a current application.

这可能吗?

当前SVG

<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" viewBox="0, 0, 1320, 800" height="800" width="1320">
  <g stroke-linejoin="round" stroke-linecap="round" fill="none" stroke="black">
    <path stroke-width="24" d="M1068,420c0,0 0,0 0,0 "/>
    <path stroke-width="27" d="M1068,420c-1,-1 -1,-1 -1,-1 "/>
    <path stroke-width="25" d="M1067,419c1,-1 1,0 3,-1 1,0 1,0 1,0 "/>
  </g>
</svg>

Primefaces签名使用字符串
例子

And Primefaces Signature uses a string
Example

{"lines":[[211.91,90.72],[209.91,90.72]]}

从svg中提取的路径.

Paths extracted from svg .

 M154,223c0,0 0,0 0,0
 M154,223c0,1 0,1 0,3
 M154,226c1,1 1,2 3,3
 M157,229c14,4 14,5 28,8
 M185,237c52,11 52,12 104,20
 M289,257c62,9 62,9 124,13 62,3 62,-1 123,0 65,1 65,2 130,3 43,0 43,0 87,-2 25,-1 26,-2 51,-6
 M804,265c10,-2 10,-3 19,-6

更新
我已尝试建议在评论中进行转换

UPDATE
I have tried Suggested Conversion in comment

但是结果不够准确,无法使用.

But the results are not accurate enough to use.

原始推荐答案

您不会(轻松)成功.我尝试搜索了很多(近两打)基于svg的签名",结果发现他们在互联网上搜索并得出以下结论:

You won't (easily) succeed. I tried and many (almost two dozen) svg based 'signatures' I found searching the internet and came to the following conclusion:

  • 大多数签名不是具有(可变)思想/宽度的线条,而是轮廓
  • 其中许多由SVG中以不同方式构造的多行组成
  • 向前写,有时回去

在某些情况下,使用引用的代码将这些路径转换为多边形会(非常)紧密,但在大多数情况下不会如此.您可能会尝试改进代码,但很可能甚至无法达到25%的准确度,我的意思是说75%的转化率不会足够接近.

Converting these paths to polygons with the referenced code will in some cases get (very) close but in most cases not. You might try improving the code but most likely you will not even get to a 25% accuracy with which I mean that 75% of the conversion will not get close enough.

这使我想到了真正的问题.这可能是 http://xyproblem.info ,我个人只是显示SVG,并且是否是因为我会选择通过PrimeFaces签名组件有选择地显示新的签名,而通过SVG有选择地显示新的签名,或者通过SVG通过轻松地

That brings me to the real issue. This might be an http://xyproblem.info and I'd personally just show the SVG and if it is because of some legacy, I'd selectively show either the new signatures via PrimeFaces signature component and the old ones via SVG or show all via SVG by easily transforming the PrimeFaces signatures to SVG

这篇关于是否可以将SVG转换为p:signature使用的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆