public class ResourceResolver extends Object
Constructor and Description |
---|
ResourceResolver(String baseUri)
Creates ResourceResolver instance.
|
Modifier and Type | Method and Description |
---|---|
void |
resetCache()
Resets the simple image cache.
|
URL |
resolveAgainstBaseUri(String uri)
Resolves a given URI against the base URI.
|
com.itextpdf.kernel.pdf.xobject.PdfImageXObject |
retrieveImage(String src)
Retrieve PdfImageXObject .
|
byte[] |
retrieveStream(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 .
|
InputStream |
retrieveStyleSheet(String uri)
Open an InputStream to a style sheet URI.
|
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 URI
InputStream
IOException
- Signals that an I/O exception has occurred.
public byte[] retrieveStream(String src)
String
.
src
- either link to file or base64 encoded stream.
public URL resolveAgainstBaseUri(String uri) throws MalformedURLException
uri
- the uri
MalformedURLException
- the malformed URL exception
public void resetCache()
Copyright © 1998–2019 iText Group NV. All rights reserved.