ApocDriver
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:
public class ApocDriver : IDriver
Inheritance: objectApocDriver
Implements:
Inherited Members
Example:
// 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));
// 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))
// 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));
// 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))
// 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));
// 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().
public ApocDriver()
Properties
Gets or sets the active ApocDriver.
public static ApocDriver ActiveDriver { get; set; }
An instance of ApocDriver created via the factory method Make().
Gets or sets the base directory used to locate external resourcs such as images.
public DirectoryInfo BaseDirectory { get; set; }
Defaults to the current working directory.
Determines if the output stream should be automatically closed upon completion of the render process.
public bool CloseOnExit { get; set; }
Gets a reference to a CredentialCache object that manages credentials for multiple Internet resources. CredentialCache
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.
Gets or sets the handler that is responsible for loading the image data for external graphics.
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.
public IRendererOptions Options { get; set; }
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.
public static string ProductKey { set; }
Renderer
RendererEngine
Determines which rendering engine to use.
public RendererEngine Renderer { get; set; }
A value from the RendererEngine enumeration.
The default value is PDF.
Methods
Constructs a new ApocDriver and registers the newly created driver as the active driver.
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.
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.
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.
public virtual void Render(string inputFile, string outputFile)
Path to an XSL-FO file
outputFilestringPath 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.
public virtual void Render(TextReader inputReader, Stream outputStream)
A character orientated stream
outputStreamStreamAny 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.
public virtual void Render(XmlDocument doc, Stream outputStream)
An in-memory representation of an XML document (DOM).
outputStreamStreamAny 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.
public void Render(XmlReader inputReader, Stream outputStream)
Reader that provides fast, non-cached, forward-only access to XML data
outputStreamStreamAny 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.
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.
A multicast delegate. The info event Apoc publishes.
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.
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.