Package com.openhtmltopdf.svgsupport
Class BatikSVGDrawer
java.lang.Object
com.openhtmltopdf.svgsupport.BatikSVGDrawer
- All Implemented Interfaces:
SVGDrawer
,Closeable
,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static enum
Nested classes/interfaces inherited from interface com.openhtmltopdf.extend.SVGDrawer
SVGDrawer.SVGImage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final boolean
private UserAgentCallback
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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, Set<String> allowedProtocols) Creates aSVGDrawer
that can allow arbitary scripts to run and allow the loading of external resources with the specified protocols. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFontFile
(File fontFile, String family, Integer weight, BaseRendererBuilder.FontStyle style) buildSVGImage
(Element svgElement, Box box, CssContext c, double cssWidth, double cssHeight, double dotsPerPixel) void
close()
void
importFontFaceRules
(List<FontFaceRule> fontFaces, SharedContext shared) void
withUserAgent
(UserAgentCallback userAgentCallback)
-
Field Details
-
allowedProtocols
-
fontResolver
-
allowScripts
private final boolean allowScripts -
allowExternalResources
private final boolean allowExternalResources -
userAgentCallback
-
-
Constructor Details
-
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
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 Details
-
withUserAgent
- Specified by:
withUserAgent
in interfaceSVGDrawer
-
buildSVGImage
public SVGDrawer.SVGImage buildSVGImage(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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
addFontFile
public void addFontFile(File fontFile, String family, Integer weight, BaseRendererBuilder.FontStyle style) throws IOException, FontFormatException - Specified by:
addFontFile
in interfaceSVGDrawer
- Throws:
IOException
FontFormatException