New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

ApocDriver provides the client with a single interface to invoking Apoc XSL-FO.

The examples belows demonstrate several ways of invoking Apoc XSL-FO. The methodology is the same regardless of how Apoc is embedded in your system (ASP.NET, WinForm, Web Service, etc).

Definition

Namespace:Telerik.Web.Apoc

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class ApocDriver : IDriver

Inheritance: objectApocDriver

Implements: IDriver

Inherited Members object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Example:

csharp
// This example demonstrates rendering an XSL-FO file to a PDF file.
ApocDriver driver = ApocDriver.Make();
driver.Render(
    new FileStream("readme.fo", FileMode.Open),
    new FileStream("readme.pdf", FileMode.Create));
csharp
// This example demonstrates rendering an XSL-FO file to a PDF file.
Dim driver As ApocDriver = ApocDriver.Make
driver.Render( _
    New FileStream("readme.fo", FileMode.Open), _
    New FileStream("readme.pdf", FileMode.Create))
csharp
// This example demonstrates rendering the result of an XSLT transformation
// into a PDF file.
ApocDriver driver = ApocDriver.Make();
driver.Render(
    XslTransformer.Transform("readme.xml", "readme.xsl"),
    new FileStream("readme.pdf", FileMode.Create));
csharp
// This example demonstrates rendering the result of an XSLT transformation
// into a PDF file.
Dim driver As ApocDriver = ApocDriver.Make
driver.Render( _
    XslTransformer.Transform("readme.xml", "readme.xsl"), _
    New FileStream("readme.pdf", FileMode.Create))
csharp
// This example demonstrates using an XmlDocument as the source of the
// XSL-FO tree.  The XmlDocument could easily be dynamically generated.
XmlDocument doc = new XmlDocument()
doc.Load("reader.fo");

ApocDriver driver = ApocDriver.Make();
driver.Render(doc, new FileStream("readme.pdf", FileMode.Create));
csharp
// This example demonstrates using an XmlDocument as the source of the
// XSL-FO tree.  The XmlDocument could easily be dynamically generated.
Dim doc As XmlDocument = New XmlDocument()
doc.Load("reader.fo")

Dim driver As ApocDriver = ApocDriver.Make
driver.Render(doc, New FileStream("readme.pdf", FileMode.Create))

Constructors

Sets the the 'baseDir' property in the Configuration class using the value returned by Directory.GetCurrentDirectory().

C#
public ApocDriver()

Properties

Gets or sets the active ApocDriver.

C#
public static ApocDriver ActiveDriver { get; set; }
Property Value:

An instance of ApocDriver created via the factory method Make().

Gets or sets the base directory used to locate external resourcs such as images.

C#
public DirectoryInfo BaseDirectory { get; set; }
Property Value:

Defaults to the current working directory.

Determines if the output stream should be automatically closed upon completion of the render process.

C#
public bool CloseOnExit { get; set; }

Gets a reference to a CredentialCache object that manages credentials for multiple Internet resources. CredentialCache

C#
public CredentialCache Credentials { get; }

The purpose of this property is to associate a set of credentials against an Internet resource. These credentials are then used by Apoc when fetching images from one of the listed resources.

Example:
C#
ApocDriver driver = ApocDriver.Make();

NetworkCredential nc1 = new NetworkCredential("foo", "password");
driver.Credentials.Add(new Uri("https://www.yoursite.com"), "Basic", nc1);

NetworkCredential nc2 = new NetworkCredential("john", "password", "UK");
driver.Credentials.Add(new Uri("https://www.yoursite.com"), "Digest", nc2);

Gets or sets the handler that is responsible for loading the image data for external graphics.

C#
public ApocDriver.ApocImageHandler ImageHandler { get; set; }

If null is returned from the image handler, then Apoc will perform normal processing.

Options

IRendererOptions

Options that are passed to the rendering engine.

C#
public IRendererOptions Options { get; set; }
Property Value:

An object that implements the IRendererOptions marker interface. The default value is null, in which case all default options will be used.

An instance of PdfRendererOptions is typically passed to this property.

Write only property that can be used to bypass licenses.licx and set a product key directly.

C#
public static string ProductKey { set; }

Renderer

RendererEngine

Determines which rendering engine to use.

C#
public RendererEngine Renderer { get; set; }
Property Value:

A value from the RendererEngine enumeration.

The default value is PDF.

Gets or sets the time in milliseconds until an HTTP image request times out.

C#
public int Timeout { get; set; }
Property Value:

The timeout value in milliseconds

The default value is 100000 milliseconds.

Methods

Constructs a new ApocDriver and registers the newly created driver as the active driver.

C#
public static ApocDriver Make()
Returns:

ApocDriver

An instance of ApocDriver

Executes the conversion reading the source tree from the input stream, converting it to a format dictated by the render and writing it to the supplied output stream.

C#
public virtual void Render(Stream inputStream, Stream outputStream)
Parameters:inputStreamStream

Any subclass of the Stream class, e.g. FileStream

outputStreamStream

Any subclass of the Stream class, e.g. FileStream

Executes the conversion reading the source tree from the file inputFile, converting it to a format dictated by the renderer and writing it to the supplied output stream.

C#
public virtual void Render(string inputFile, Stream outputStream)
Parameters:inputFilestring

Path to an XSL-FO file

outputStreamStream

Any subclass of the Stream class, e.g. FileStream

Executes the conversion reading the source tree from the file inputFile, converting it to a format dictated by the renderer and writing it to the file identified by outputFile.

C#
public virtual void Render(string inputFile, string outputFile)
Parameters:inputFilestring

Path to an XSL-FO file

outputFilestring

Path to a file

If the file outputFile does not exist, it will created otherwise it will be overwritten. Creating a file may generate a variety of exceptions. See FileStream for a complete list.

Executes the conversion reading the source tree from the input reader, converting it to a format dictated by the renderer and writing it to the supplied output stream.

C#
public virtual void Render(TextReader inputReader, Stream outputStream)
Parameters:inputReaderTextReader

A character orientated stream

outputStreamStream

Any subclass of the Stream class

Executes the conversion reading the source tree from the supplied XmlDocument, converting it to a format dictated by the renderer and writing it to the supplied output stream.

C#
public virtual void Render(XmlDocument doc, Stream outputStream)
Parameters:docXmlDocument

An in-memory representation of an XML document (DOM).

outputStreamStream

Any subclass of the Stream class.

Any exceptions that occur during the render process are arranged into three categories: information, warning and error. You may intercept any or all of theses exceptional states by registering an event listener. See OnError for an example of registering an event listener. If there are no registered listeners, the exceptions are dumped to standard out - except for the error event which is wrapped in a SystemException.

Executes the conversion reading the source tree from the input reader, converting it to a format dictated by the render and writing it to the supplied output stream.

C#
public void Render(XmlReader inputReader, Stream outputStream)
Parameters:inputReaderXmlReader

Reader that provides fast, non-cached, forward-only access to XML data

outputStreamStream

Any subclass of the Stream class, e.g. FileStream

The evaluation copy of this class will output an evaluation banner to standard out

Events

A multicast delegate. The error event Apoc publishes.

C#
public event ApocDriver.ApocEventHandler OnError

The method signature for this event handler should match the following:


                void ApocError(object driver, ApocEventArgs e);
                

The first parameter driver will be a reference to the active ApocDriver instance.

Example:
C#
{
ApocDriver driver = ApocDriver.Make();
driver.OnError += new ApocDriver.ApocEventHandler(ApocError);
...
}

A multicast delegate. The info event Apoc publishes.

C#
public event ApocDriver.ApocEventHandler OnInfo

The method signature for this event handler should match the following:


                void ApocInfo(object driver, ApocEventArgs e);
                

The first parameter driver will be a reference to the active ApocDriver instance.

A multicast delegate. The warning event Apoc publishes.

C#
public event ApocDriver.ApocEventHandler OnWarning

The method signature for this event handler should match the following:


                void ApocWarning(object driver, ApocEventArgs e);
                

The first parameter driver will be a reference to the active ApocDriver instance.