public class ResourceResolver extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
BASE64IDENTIFIER
Identifier string used when loading in base64 images
|
| Constructor and Description |
|---|
ResourceResolver(String baseUri)
Creates
ResourceResolver instance. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isImageTypeSupportedByImageDataFactory(String src)
Check if the type of image located at the passed is supported by the
ImageDataFactory |
void |
resetCache()
Resets the simple image cache.
|
URL |
resolveAgainstBaseUri(String uri)
Resolves a given URI against the base URI.
|
byte[] |
retrieveBytesFromResource(String src)
Retrieve a resource as a byte array from a source that
can either be a link to a file, or a base64 encoded
String. |
com.itextpdf.kernel.pdf.xobject.PdfImageXObject |
retrieveImage(String src)
Retrieve
PdfImageXObject. |
InputStream |
retrieveResourceAsInputStream(String src)
Retrieve the resource found in src as an InputStream
|
byte[] |
retrieveStream(String src)
Deprecated.
|
InputStream |
retrieveStyleSheet(String uri)
Open an
InputStream to a style sheet URI. |
public static final String BASE64IDENTIFIER
public ResourceResolver(String baseUri)
ResourceResolver instance. If baseUri 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.
The main difference between those two is handling of the relative URIs of resources with slashes in the beginning of them (e.g. "/test/uri", or "//itextpdf.com/example_resources/logo.img"): if base URI is handled as local file system path, then in those cases resources URIs will be simply concatenated to the base path, rather than processed with URI resolution rules (See RFC 3986 "5.4. Reference Resolution Examples"). However absolute resource URIs will be processed correctly.
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.
baseUri - base URI against which all relative resource URIs will be resolved.public com.itextpdf.kernel.pdf.xobject.PdfImageXObject retrieveImage(String src)
PdfImageXObject.src - either link to file or base64 encoded stream.public InputStream retrieveStyleSheet(String uri) throws IOException
InputStream to a style sheet URI.uri - the URIInputStreamIOException - Signals that an I/O exception has occurred.@Deprecated public byte[] retrieveStream(String src)
String.src - either link to file or base64 encoded stream.public byte[] retrieveBytesFromResource(String src)
String.src - either link to file or base64 encoded stream.public InputStream retrieveResourceAsInputStream(String src)
src - path to the resourcepublic URL resolveAgainstBaseUri(String uri) throws MalformedURLException
uri - the uriMalformedURLException - the malformed URL exceptionpublic void resetCache()
public boolean isImageTypeSupportedByImageDataFactory(String src)
ImageDataFactorysrc - location of the image resourceCopyright © 1998–2018 iText Group NV. All rights reserved.