Hi, StackOverflow,
First question from me; I'm currently fixing a graphing service that uses XSLFO to convert our syntax to FO, and converting it to PDF in the end.
Previously we've been using PNG graphs from the web in the PDF exports, but this creates really ugly results, so we've decided to go with SVG for PDF instead.
However, the SVG doesn't seem to scale into the SVG canvas properly.
Here is the syntax before run into XSLFO:
<img src="someimage.svg">
And here is the XSLFO I'm using:
<xsl:template match="img">
<fo:block space-after="12pt">
<fo:instream-foreign-object width="20cm" height="15cm" content-width="scale-to-fit" content-height="scale-to-fit" scaling="uniform" background-color="#cccccc">
<svg:svg x="0" y="0" width="100" height="100" viewBox="0 0 100 100">
<svg:image x="0" y="0" width="100" height="100">
<xsl:if test="@src">
<xsl:attribute name="xlink:href">
<xsl:choose>
<xsl:when test="starts-with(@src, 'http://')">
<xsl:value-of select="@src"/>
</xsl:when>
<xsl:when test="starts-with(@src, 'https://')">
<xsl:value-of select="@src"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($baseurl, @src)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
</svg:image>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</xsl:template>
The SVG does appear in the PDF, and it does seem contained within the canvas - but for whatever reason I cannot get it to scale properly. It's just really, really huge, and the result being an extremely cropped version of the SVG.
I'm running out of suggestions here - is there anyone here that has experience with this?
PS: The image is created using the newest version of Batik, and the width and height is set properly.