iText 7 7.2.2 API
iText.StyledXmlParser.Resolver.Resource.ResourceResolver Class Reference

Utilities class to resolve resources. More...

Public Member Functions

  ResourceResolver (String baseUri)
  Creates a new ResourceResolver instance. More...
 
  ResourceResolver (String baseUri, IResourceRetriever retriever)
  Creates a new ResourceResolver instance. More...
 
virtual IResourceRetriever  GetRetriever ()
  Gets the resource retriever. More...
 
virtual iText.StyledXmlParser.Resolver.Resource.ResourceResolver  SetRetriever (IResourceRetriever retriever)
  Sets the resource retriever. More...
 
virtual PdfXObject  RetrieveImage (String src)
  Retrieve image as either iText.Kernel.Pdf.Xobject.PdfImageXObject , or iText.Kernel.Pdf.Xobject.PdfFormXObject. More...
 
virtual 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 System.String. More...
 
virtual Stream  RetrieveResourceAsInputStream (String src)
  Retrieve the resource found in src as an InputStream More...
 
virtual Uri  ResolveAgainstBaseUri (String uri)
  Resolves a given URI against the base URI. More...
 
virtual void  ResetCache ()
  Resets the simple image cache. More...
 

Static Public Member Functions

static bool  IsDataSrc (String src)
  Checks if source is under data URI scheme. More...
 

Static Public Attributes

const String  BASE64_IDENTIFIER = "base64"
  Identifier string used when loading in base64 images. More...
 
const String  DATA_SCHEMA_PREFIX = "data:"
  Identifier string used to detect that the source is under data URI scheme. More...
 

Detailed Description

Utilities class to resolve resources.

Constructor & Destructor Documentation

◆ ResourceResolver() [1/2]

iText.StyledXmlParser.Resolver.Resource.ResourceResolver.ResourceResolver ( String  baseUri )
inline

Creates a new ResourceResolver instance.

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.

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

◆ ResourceResolver() [2/2]

iText.StyledXmlParser.Resolver.Resource.ResourceResolver.ResourceResolver ( String  baseUri,
IResourceRetriever  retriever 
)
inline

Creates a new ResourceResolver instance.

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.

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
retriever the resource retriever with the help of which data from resources will be retrieved

Member Function Documentation

◆ GetRetriever()

virtual IResourceRetriever iText.StyledXmlParser.Resolver.Resource.ResourceResolver.GetRetriever ( )
inlinevirtual

Gets the resource retriever.

Gets the resource retriever. The retriever is used to retrieve data from resources by URL.

Returns
the resource retriever

◆ IsDataSrc()

static bool iText.StyledXmlParser.Resolver.Resource.ResourceResolver.IsDataSrc ( String  src )
inlinestatic

Checks if source is under data URI scheme.

Checks if source is under data URI scheme. (eg data:[][;base64],).

Parameters
src string to test
Returns
true if source is under data URI scheme

◆ ResetCache()

virtual void iText.StyledXmlParser.Resolver.Resource.ResourceResolver.ResetCache ( )
inlinevirtual

Resets the simple image cache.

◆ ResolveAgainstBaseUri()

virtual Uri iText.StyledXmlParser.Resolver.Resource.ResourceResolver.ResolveAgainstBaseUri ( String  uri )
inlinevirtual

Resolves a given URI against the base URI.

Parameters
uri the uri
Returns
the url

◆ RetrieveBytesFromResource()

virtual byte [] iText.StyledXmlParser.Resolver.Resource.ResourceResolver.RetrieveBytesFromResource ( String  src )
inlinevirtual

Retrieve a resource as a byte array from a source that can either be a link to a file, or a base64 encoded System.String.

Parameters
src either link to file or base64 encoded stream
Returns
byte[] on success, otherwise null

◆ RetrieveImage()

virtual PdfXObject iText.StyledXmlParser.Resolver.Resource.ResourceResolver.RetrieveImage ( String  src )
inlinevirtual

Retrieve image as either iText.Kernel.Pdf.Xobject.PdfImageXObject , or iText.Kernel.Pdf.Xobject.PdfFormXObject.

Parameters
src either link to file or base64 encoded stream
Returns
PdfXObject on success, otherwise null

◆ RetrieveResourceAsInputStream()

virtual Stream iText.StyledXmlParser.Resolver.Resource.ResourceResolver.RetrieveResourceAsInputStream ( String  src )
inlinevirtual

Retrieve the resource found in src as an InputStream

Parameters
src path to the resource
Returns
InputStream for the resource on success, otherwise null

◆ SetRetriever()

virtual iText.StyledXmlParser.Resolver.Resource.ResourceResolver iText.StyledXmlParser.Resolver.Resource.ResourceResolver.SetRetriever ( IResourceRetriever  retriever )
inlinevirtual

Sets the resource retriever.

Sets the resource retriever. The retriever is used to retrieve data from resources by URL.

Parameters
retriever the resource retriever
Returns
the ResourceResolver instance

Member Data Documentation

◆ BASE64_IDENTIFIER

const String iText.StyledXmlParser.Resolver.Resource.ResourceResolver.BASE64_IDENTIFIER = "base64"
static

Identifier string used when loading in base64 images.

◆ DATA_SCHEMA_PREFIX

const String iText.StyledXmlParser.Resolver.Resource.ResourceResolver.DATA_SCHEMA_PREFIX = "data:"
static

Identifier string used to detect that the source is under data URI scheme.