Class HtmlResourceResolver
java.lang.Object
com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
com.itextpdf.html2pdf.resolver.resource.HtmlResourceResolver
public class HtmlResourceResolver extends com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
Extends
ResourceResolver
to also support SVG images
-
Field Summary
Fields inherited from class com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
BASE64_IDENTIFIER, DATA_SCHEMA_PREFIX
-
Constructor Summary
ConstructorDescriptionHtmlResourceResolver
(String baseUri, ProcessorContext context) Creates a newHtmlResourceResolver
instance.HtmlResourceResolver
(String baseUri, ProcessorContext context, com.itextpdf.styledxmlparser.resolver.resource.IResourceRetriever retriever) Creates a newHtmlResourceResolver
instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.itextpdf.kernel.pdf.xobject.PdfXObject
createImageByUrl
(URL url) com.itextpdf.kernel.pdf.xobject.PdfXObject
retrieveImage
(String src) protected com.itextpdf.kernel.pdf.xobject.PdfXObject
Retrieve image as eitherPdfImageXObject
, orPdfFormXObject
.Methods inherited from class com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
getRetriever, isDataSrc, resetCache, resolveAgainstBaseUri, retrieveBytesFromResource, retrieveResourceAsInputStream, setRetriever, tryResolveUrlImageSource
-
Constructor Details
-
HtmlResourceResolver
Creates a newHtmlResourceResolver
instance. IfbaseUri
is a string that represents an absolute URI with any schema except "file" - resources url values will be resolved exactly as "new URL(baseUrl, uriString)". Otherwise base URI will be handled as path in local file system.If empty string or relative URI string is passed as base URI, then it will be resolved against current working directory of this application instance.
- Parameters:
-
baseUri
- base URI against which all relative resource URIs will be resolved -
context
-ProcessorContext
instance for the current HTML to PDF conversion process
-
HtmlResourceResolver
public HtmlResourceResolver(String baseUri, ProcessorContext context, com.itextpdf.styledxmlparser.resolver.resource.IResourceRetriever retriever) Creates a newHtmlResourceResolver
instance. IfbaseUri
is a string that represents an absolute URI with any schema except "file" - resources url values will be resolved exactly as "new URL(baseUrl, uriString)". Otherwise base URI will be handled as path in local file system.If empty string or relative URI string is passed as base URI, then it will be resolved against current working directory of this application instance.
- Parameters:
-
baseUri
- base URI against which all relative resource URIs will be resolved -
context
-ProcessorContext
instance for the current HTML to PDF conversion process -
retriever
- the resource retriever with the help of which data from resources will be retrieved
-
-
Method Details
-
retrieveImage
- Overrides:
-
retrieveImage
in classcom.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
-
tryResolveBase64ImageSource
Retrieve image as eitherPdfImageXObject
, orPdfFormXObject
.- Overrides:
-
tryResolveBase64ImageSource
in classcom.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
- Parameters:
-
src
- either link to file or base64 encoded stream - Returns:
- PdfXObject on success, otherwise null
-
createImageByUrl
- Overrides:
-
createImageByUrl
in classcom.itextpdf.styledxmlparser.resolver.resource.ResourceResolver
- Throws:
-
Exception
-