Reputation: 69
I am trying to implement SVG inside an instream-foreign-object below is the code snip it; this is a code section from a XSLT (1.0);
<xsl:template name="Draft">
<fo:block-container>
<fo:block>
<fo:instream-foreign-object>
<svg:svg xmlns:svg="http://www.w3.org/2000/svg" xml:base="http://example.org/today/" >
<svg:defs>
<svg:font-face font-family="sample">
<svg:font-face-src>
<svg:font-face-uri href="sample.ttf"/>
</svg:font-face-src>
</svg:font-face>
</svg:defs>
<svg:text>
DRAFT
</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
</xsl:template>
now when I am trying to convert from xml to pdf it is giving me below error:
org.apache.fop.fo.extensions.svg.SVGElement.getDimension Could not set base URL for svg
java.lang.IllegalArgumentException: URI is not absolute
at java.base/java.net.URL.fromURI(URL.java:721)
at java.base/java.net.URI.toURL(URI.java:1139)
at org.apache.fop.fo.extensions.svg.SVGElement.getDimension(SVGElement.java:77)
.
.
.
So can you please help me to understand why we are seeing this error?
Upvotes: 0
Views: 208
Reputation: 8068
Because you are running FOP from the command line, your document has a base URI. Now that you've shown that you can have sample.ttf
on your file system, I suggest putting the full path to sample.ttf
<svg:svg xmlns:svg="w3.org/2000/svg">
<svg:defs>
<svg:font-face font-family="sample">
<svg:font-face-src>
<svg:font-face-uri href="file:///PATH/for/config/sample.ttf"/>
</svg:font-face-src>
</svg:font-face>
</svg:defs>
<svg:text> DRAFT </svg:text>
</svg:svg>
From https://xmlgraphics.apache.org/fop/faq.html#svg-url, it appears that FOP could find the font from a HTTP URL.
Upvotes: 0