public class ResourceResolver extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BASE64IDENTIFIER
Identifier string used when loading in base64 images
|
static String |
DATA_SCHEMA_PREFIX |
Constructor and Description |
---|
ResourceResolver(String baseUri)
Creates ResourceResolver instance.
|
Modifier and Type | Method and Description |
---|---|
protected PdfXObject |
createImageByUrl(URL url)
Create a iText XObject based on the image stored at the passed location
|
boolean |
isDataSrc(String src)
Checks if source is under data URI scheme.
|
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 .
|
PdfImageXObject |
retrieveImage(String src)
Deprecated.
will return
in pdfHTML 3.0.0
|
PdfXObject |
retrieveImageExtended(String src)
Retrieve image as either PdfImageXObject , or PdfFormXObject .
|
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.
|
protected PdfXObject |
tryResolveBase64ImageSource(String src) |
protected PdfXObject |
tryResolveUrlImageSource(String uri) |
public static final String BASE64IDENTIFIER
public static final String DATA_SCHEMA_PREFIX
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.
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.
@Deprecated public PdfImageXObject retrieveImage(String src)
in pdfHTML 3.0.0
PdfImageXObject
.
src
- either link to file or base64 encoded stream.
public PdfXObject retrieveImageExtended(String src)
PdfImageXObject
, or PdfFormXObject
.
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.
@Deprecated public 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
.
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 resource
public URL resolveAgainstBaseUri(String uri) throws MalformedURLException
uri
- the uri
MalformedURLException
- the malformed URL exception
public void resetCache()
public boolean isImageTypeSupportedByImageDataFactory(String src)
ImageDataFactory
src
- location of the image resource
protected PdfXObject tryResolveBase64ImageSource(String src)
protected PdfXObject tryResolveUrlImageSource(String uri)
protected PdfXObject createImageByUrl(URL url) throws Exception
url
- location of the Image file
PdfXObject
containing the Image loaded in
Exception
- thrown if error occurred during fetching or constructing the image
public boolean isDataSrc(String src)
src
- String to test
Copyright © 1998–2020 iText Group NV. All rights reserved.