Package com.openhtmltopdf.svgsupport
Class BatikSVGDrawer
- java.lang.Object
-
- com.openhtmltopdf.svgsupport.BatikSVGDrawer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBatikSVGDrawer.SvgExternalResourceModestatic classBatikSVGDrawer.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>allowedProtocolsprivate booleanallowExternalResourcesprivate booleanallowScriptsPDFTranscoder.OpenHtmlFontResolverfontResolverprivate UserAgentCallbackuserAgentCallback
-
Constructor Summary
Constructors Constructor Description BatikSVGDrawer()Creates aSVGDrawerthat 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 aSVGDrawerthat 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 aSVGDrawerthat 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 voidaddFontFile(java.io.File fontFile, java.lang.String family, java.lang.Integer weight, BaseRendererBuilder.FontStyle style)SVGDrawer.SVGImagebuildSVGImage(org.w3c.dom.Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel)voidclose()voidimportFontFaceRules(java.util.List<FontFaceRule> fontFaces, SharedContext shared)voidwithUserAgent(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 aSVGDrawerthat 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 aSVGDrawerthat can allow arbitary scripts to run and allow the loading of external resources with the specified protocols.- Parameters:
scriptMode-allowedProtocols-
-
BatikSVGDrawer
public BatikSVGDrawer()
Creates aSVGDrawerthat 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:
importFontFaceRulesin interfaceSVGDrawer
-
withUserAgent
public void withUserAgent(UserAgentCallback userAgentCallback)
- Specified by:
withUserAgentin interfaceSVGDrawer
-
buildSVGImage
public SVGDrawer.SVGImage buildSVGImage(org.w3c.dom.Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel)
- Specified by:
buildSVGImagein interfaceSVGDrawer
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein 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:
addFontFilein interfaceSVGDrawer- Throws:
java.io.IOExceptionjava.awt.FontFormatException
-
-