【发布时间】:2021-10-30 05:41:21
【问题描述】:
生成的条形码以 HTML 标记的形式显示,因此无法右键单击并保存为图像。下面是生成的条形码的示例。我的浏览器(Chrome、Firefox、Safari)中是否有任何方法可以将其转换为图像文件,或者可能是我可以使用的 SVG(矢量)文件?如果可能,我宁愿不必更改源代码。
<svg class="barcode" jsbarcode-width="1" jsbarcode-height="22" jsbarcode-textalign="center" jsbarcode-textposition="bottom" jsbarcode-displayvalue="true" jsbarcode-font="monospace" jsbarcode-fontstyle="monospace" jsbarcode-fontsize="14" jsbarcode-background="#FFFFFF"
jsbarcode-linecolor="#000000" jsbarcode-textmargin="5" jsbarcode-fontoptions="0 0" jsbarcode-format="code128" jsbarcode-value="0219000780318" width="143px" height="61px" x="0px" y="0px" viewBox="0 0 143 61" xmlns="http://www.w3.org/2000/svg" version="1.1"
style="transform: translate(0px, 0px);">
<rect x="0" y="0" width="143" height="61" style="fill:#FFFFFF;"></rect>
<g transform="translate(10, 10)" style="fill:#000000;">
<rect x="0" y="0" width="2" height="22"></rect>
<rect x="3" y="0" width="1" height="22"></rect>
<rect x="6" y="0" width="3" height="22"></rect>
<rect x="11" y="0" width="2" height="22"></rect>
<rect x="15" y="0" width="2" height="22"></rect>
<rect x="19" y="0" width="2" height="22"></rect>
<rect x="22" y="0" width="2" height="22"></rect>
<rect x="26" y="0" width="1" height="22"></rect>
<rect x="28" y="0" width="3" height="22"></rect>
<rect x="33" y="0" width="2" height="22"></rect>
<rect x="36" y="0" width="2" height="22"></rect>
<rect x="40" y="0" width="2" height="22"></rect>
<rect x="44" y="0" width="1" height="22"></rect>
<rect x="47" y="0" width="2" height="22"></rect>
<rect x="52" y="0" width="1" height="22"></rect>
<rect x="55" y="0" width="1" height="22"></rect>
<rect x="57" y="0" width="1" height="22"></rect>
<rect x="60" y="0" width="4" height="22"></rect>
<rect x="66" y="0" width="2" height="22"></rect>
<rect x="69" y="0" width="2" height="22"></rect>
<rect x="74" y="0" width="2" height="22"></rect>
<rect x="77" y="0" width="3" height="22"></rect>
<rect x="81" y="0" width="1" height="22"></rect>
<rect x="83" y="0" width="4" height="22"></rect>
<rect x="88" y="0" width="3" height="22"></rect>
<rect x="92" y="0" width="1" height="22"></rect>
<rect x="95" y="0" width="2" height="22"></rect>
<rect x="99" y="0" width="2" height="22"></rect>
<rect x="103" y="0" width="1" height="22"></rect>
<rect x="107" y="0" width="1" height="22"></rect>
<rect x="110" y="0" width="2" height="22"></rect>
<rect x="115" y="0" width="3" height="22"></rect>
<rect x="119" y="0" width="1" height="22"></rect>
<rect x="121" y="0" width="2" height="22"></rect>
<text style="font:0 0 14px monospace" text-anchor="middle" x="61.5" y="41">0219000780318</text>
</g>
</svg>
【问题讨论】:
-
如果唯一可能的方式是使用代码,那么开发人员的方式就可以了。但我更喜欢最终用户的方式,因为这样可以节省我一些时间。
-
啊...解决方案仅供我自己使用,是的,如果有一个可以解决问题的浏览器扩展程序,当然!
-
确实如此。我希望找到另一种方法,甚至可以从中保存 SVG 矢量文件。
标签: javascript html image svg barcode