Class ResourceResolver
- Namespace
- iText.StyledXmlParser.Resolver.Resource
- Assembly
- itext.styledxmlparser.dll
Utilities class to resolve resources.
public class ResourceResolver
- Inheritance
-
ResourceResolver
- Inherited Members
Constructors
ResourceResolver(string)
Creates a new ResourceResolver instance.
public ResourceResolver(string baseUri)
Parameters
baseUri
stringbase URI against which all relative resource URIs will be resolved
Remarks
Creates a new
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.
ResourceResolver(string, IResourceRetriever)
Creates a new ResourceResolver instance.
public ResourceResolver(string baseUri, IResourceRetriever retriever)
Parameters
baseUri
stringbase URI against which all relative resource URIs will be resolved
retriever
IResourceRetrieverthe resource retriever with the help of which data from resources will be retrieved
Remarks
Creates a new
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.
Fields
BASE64_IDENTIFIER
Identifier string used when loading in base64 images.
public const string BASE64_IDENTIFIER = "base64"
Field Value
DATA_SCHEMA_PREFIX
Identifier string used to detect that the source is under data URI scheme.
public const string DATA_SCHEMA_PREFIX = "data:"
Field Value
Methods
CreateImageByUrl(Uri)
Create a iText XObject based on the image stored at the passed location.
protected virtual PdfXObject CreateImageByUrl(Uri url)
Parameters
url
Urilocation of the Image file.
Returns
- PdfXObject
PdfXObject containing the Image loaded in.
GetRetriever()
Gets the resource retriever.
public virtual IResourceRetriever GetRetriever()
Returns
- IResourceRetriever
the resource retriever
Remarks
Gets the resource retriever. The retriever is used to retrieve data from resources by URL.
IsDataSrc(string)
Checks if source is under data URI scheme.
public static bool IsDataSrc(string src)
Parameters
src
stringstring to test
Returns
- bool
true if source is under data URI scheme
Remarks
Checks if source is under data URI scheme. (eg data:[<media type>][;base64],<data>).
ResetCache()
Resets the simple image cache.
public virtual void ResetCache()
ResolveAgainstBaseUri(string)
Resolves a given URI against the base URI.
public virtual Uri ResolveAgainstBaseUri(string uri)
Parameters
uri
stringthe uri
Returns
- Uri
the url
RetrieveBytesFromResource(string)
Retrieve a resource as a byte array from a source that can either be a link to a file, or a base64 encoded string.
public virtual byte[] RetrieveBytesFromResource(string src)
Parameters
src
stringeither link to file or base64 encoded stream
Returns
- byte[]
byte[] on success, otherwise null
RetrieveImage(string)
Retrieve image as either PdfImageXObject , or PdfFormXObject.
public virtual PdfXObject RetrieveImage(string src)
Parameters
src
stringeither link to file or base64 encoded stream
Returns
- PdfXObject
PdfXObject on success, otherwise null
RetrieveResourceAsInputStream(string)
Retrieve the resource found in src as an InputStream
public virtual Stream RetrieveResourceAsInputStream(string src)
Parameters
src
stringpath to the resource
Returns
- Stream
InputStream for the resource on success, otherwise null
SetRetriever(IResourceRetriever)
Sets the resource retriever.
public virtual ResourceResolver SetRetriever(IResourceRetriever retriever)
Parameters
retriever
IResourceRetrieverthe resource retriever
Returns
- ResourceResolver
the ResourceResolver instance
Remarks
Sets the resource retriever. The retriever is used to retrieve data from resources by URL.
TryResolveBase64ImageSource(string)
protected virtual PdfXObject TryResolveBase64ImageSource(string src)
Parameters
src
string
Returns
TryResolveUrlImageSource(string)
protected virtual PdfXObject TryResolveUrlImageSource(string uri)
Parameters
uri
string