Package com.openhtmltopdf.svgsupport
Class BatikSVGDrawer
- java.lang.Object
-
- com.openhtmltopdf.svgsupport.BatikSVGDrawer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BatikSVGDrawer.SvgExternalResourceMode
static class
BatikSVGDrawer.SvgScriptMode
-
Nested classes/interfaces inherited from interface com.openhtmltopdf.extend.SVGDrawer
SVGDrawer.SVGImage
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>
allowedProtocols
private boolean
allowExternalResources
private boolean
allowScripts
PDFTranscoder.OpenHtmlFontResolver
fontResolver
private UserAgentCallback
userAgentCallback
-
Constructor Summary
Constructors Constructor Description BatikSVGDrawer()
Creates aSVGDrawer
that does NOT allow scripts to run or external resources such asfile://
orhttp://
protocol urls to be requested.BatikSVGDrawer(BatikSVGDrawer.SvgScriptMode scriptMode, BatikSVGDrawer.SvgExternalResourceMode externalResourceMode)
Creates aSVGDrawer
that can allow arbitary scripts to run or allow arbitary external resources to be requested.BatikSVGDrawer(BatikSVGDrawer.SvgScriptMode scriptMode, java.util.Set<java.lang.String> allowedProtocols)
Creates aSVGDrawer
that can allow arbitary scripts to run and allow the loading of external resources with the specified protocols.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFontFile(java.io.File fontFile, java.lang.String family, java.lang.Integer weight, BaseRendererBuilder.FontStyle style)
SVGDrawer.SVGImage
buildSVGImage(org.w3c.dom.Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel)
void
close()
void
importFontFaceRules(java.util.List<FontFaceRule> fontFaces, SharedContext shared)
void
withUserAgent(UserAgentCallback userAgentCallback)
-
-
-
Field Detail
-
allowedProtocols
private final java.util.Set<java.lang.String> allowedProtocols
-
fontResolver
public PDFTranscoder.OpenHtmlFontResolver fontResolver
-
allowScripts
private final boolean allowScripts
-
allowExternalResources
private final boolean allowExternalResources
-
userAgentCallback
private UserAgentCallback userAgentCallback
-
-
Constructor Detail
-
BatikSVGDrawer
public BatikSVGDrawer(BatikSVGDrawer.SvgScriptMode scriptMode, BatikSVGDrawer.SvgExternalResourceMode externalResourceMode)
Creates aSVGDrawer
that can allow arbitary scripts to run or allow arbitary external resources to be requested. IMPORTANT: External resources include thefile://
protocol and may give an attacker access to all files on the system. Scripts may call Javascript or Java code and take control of the system. Please be very sure you are ONLY using trusted SVGs before using this constructor!
-
BatikSVGDrawer
public BatikSVGDrawer(BatikSVGDrawer.SvgScriptMode scriptMode, java.util.Set<java.lang.String> allowedProtocols)
Creates aSVGDrawer
that can allow arbitary scripts to run and allow the loading of external resources with the specified protocols.- Parameters:
scriptMode
-allowedProtocols
-
-
BatikSVGDrawer
public BatikSVGDrawer()
Creates aSVGDrawer
that does NOT allow scripts to run or external resources such asfile://
orhttp://
protocol urls to be requested. Recommended for most users.
-
-
Method Detail
-
importFontFaceRules
public void importFontFaceRules(java.util.List<FontFaceRule> fontFaces, SharedContext shared)
- Specified by:
importFontFaceRules
in interfaceSVGDrawer
-
withUserAgent
public void withUserAgent(UserAgentCallback userAgentCallback)
- Specified by:
withUserAgent
in interfaceSVGDrawer
-
buildSVGImage
public SVGDrawer.SVGImage buildSVGImage(org.w3c.dom.Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel)
- Specified by:
buildSVGImage
in interfaceSVGDrawer
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
addFontFile
public void addFontFile(java.io.File fontFile, java.lang.String family, java.lang.Integer weight, BaseRendererBuilder.FontStyle style) throws java.io.IOException, java.awt.FontFormatException
- Specified by:
addFontFile
in interfaceSVGDrawer
- Throws:
java.io.IOException
java.awt.FontFormatException
-
-