Package com.openhtmltopdf.svgsupport
Class BatikSVGDrawer
- java.lang.Object
-
- com.openhtmltopdf.svgsupport.BatikSVGDrawer
-
- All Implemented Interfaces:
SVGDrawer,Closeable,AutoCloseable
public class BatikSVGDrawer extends Object implements SVGDrawer
-
-
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 PDFTranscoder.OpenHtmlFontResolverfontResolver
-
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, Set<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(File fontFile, String family, Integer weight, BaseRendererBuilder.FontStyle style)SVGDrawer.SVGImagebuildSVGImage(Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel)voidclose()voidimportFontFaceRules(List<FontFaceRule> fontFaces, SharedContext shared)voidwithUserAgent(UserAgentCallback userAgentCallback)
-
-
-
Field Detail
-
fontResolver
public PDFTranscoder.OpenHtmlFontResolver fontResolver
-
-
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, Set<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(List<FontFaceRule> fontFaces, SharedContext shared)
- Specified by:
importFontFaceRulesin interfaceSVGDrawer
-
withUserAgent
public void withUserAgent(UserAgentCallback userAgentCallback)
- Specified by:
withUserAgentin interfaceSVGDrawer
-
buildSVGImage
public SVGDrawer.SVGImage buildSVGImage(Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel)
- Specified by:
buildSVGImagein interfaceSVGDrawer
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
addFontFile
public void addFontFile(File fontFile, String family, Integer weight, BaseRendererBuilder.FontStyle style) throws IOException, FontFormatException
- Specified by:
addFontFilein interfaceSVGDrawer- Throws:
IOExceptionFontFormatException
-
-