<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@fill[ancestor::svg:symbol]" priority="1">
<xsl:attribute name="fill">currentColor</xsl:attribute>
</xsl:template>
<xsl:template match="@filter[starts-with(.,'url(#colorFilter-')]">
<xsl:attribute name="color">
<xsl:value-of select="concat('#',substring(.,18,6))"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="svg:use[not(@filter)]">
<xsl:copy>
<xsl:attribute name="color">#fff</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
0.4 0 0 0 0
0 0.6 0 0 0
0 0 0.8 0 0
0 0 0 1 0
rgba(40%,60%,80%,1)
。<svg xmlns="http://www.w3.org/2000/svg"> <g transform='translate(0.0,39.75)'><text x='65.0' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='12' font-family='Arial' fill='#000000' >测试</tspan></text></g> </svg>
并运行了以下命令:
java -jar batik-rasterizer.jar -m application/pdf ..\test.svg -font-family Arial
从PDF查看器中无法选择文本。该文本被转换为矢量图像。 - user2233706rasterizer -m application/pdf test.svg
,并且可以使用Adobe Reader或Evince完美地选择文本。您使用的是哪个PDF阅读器? - Thomas Wrsvg-convert
,它是 librsvg 的一部分。我曾用它将 SVG 文档转换为 PDF,并且它可以保留文本,使得在 PDF 查看器中可以选择和搜索。
这里有一篇博客文章将其与其他选项进行了比较,并展示了如何使用它:https://www.itsfullofstars.de/tag/rsvg-convert/
你尝试过将SVG打印到PDF打印机上吗?