Class ApocDriver
ApocDriver provides the client with a single interface to invoking Apoc XSL-FO.
Inheritance
Inherited Members
Namespace: Telerik.Apoc
Assembly: TelerikData.dll
Syntax
public class ApocDriver : IDriver
Remarks
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).
Examples
// 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
ApocDriver()
Sets the the 'baseDir' property in the Configuration class using the value returned by Directory.GetCurrentDirectory().
Declaration
public ApocDriver()
Properties
ActiveDriver
Gets or sets the active ApocDriver.
Declaration
public static ApocDriver ActiveDriver { get; set; }
Property Value
ApocDriver
An instance of ApocDriver created via the factory method Make(). |
BaseDirectory
Gets or sets the base directory used to locate external resourcs such as images.
Declaration
public DirectoryInfo BaseDirectory { get; set; }
Property Value
System.IO.DirectoryInfo
Defaults to the current working directory. |
Implements
CloseOnExit
Determines if the output stream should be automatically closed upon completion of the render process.
Declaration
public bool CloseOnExit { get; set; }
Property Value
System.Boolean
|
Implements
Credentials
Gets a reference to a System.Net.CredentialCache object that manages credentials for multiple Internet resources. System.Net.CredentialCache
Declaration
public CredentialCache Credentials { get; }
Property Value
System.Net.CredentialCache
|
Implements
Remarks
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.
Examples
ApocDriver driver = ApocDriver.Make();
NetworkCredential nc1 = new NetworkCredential("foo", "password"); driver.Credentials.Add(new Uri("http://www.chive.com"), "Basic", nc1);
NetworkCredential nc2 = new NetworkCredential("john", "password", "UK"); driver.Credentials.Add(new Uri("http://www.xyz.com"), "Digest", nc2);
ImageHandler
Gets or sets the handler that is responsible for loading the image data for external graphics.
Declaration
public ApocDriver.ApocImageHandler ImageHandler { get; set; }
Property Value
ApocDriver.ApocImageHandler
|
Remarks
If null is returned from the image handler, then Apoc will perform normal processing.
Options
Options that are passed to the rendering engine.
Declaration
public IRendererOptions Options { get; set; }
Property Value
IRendererOptions
An object that implements the IRendererOptions marker interface. The default value is null, in which case all default options will be used. |
Implements
Remarks
An instance of PdfRendererOptions is typically passed to this property.
ProductKey
Write only property that can be used to bypass licenses.licx and set a product key directly.
Declaration
public static string ProductKey { set; }
Property Value
System.String
|
Renderer
Determines which rendering engine to use.
Declaration
public RendererEngine Renderer { get; set; }
Property Value
RendererEngine
A value from the RendererEngine enumeration. |
Implements
Remarks
The default value is PDF.
Timeout
Gets or sets the time in milliseconds until an HTTP image request times out.
Declaration
public int Timeout { get; set; }
Property Value
System.Int32
The timeout value in milliseconds |
Implements
Remarks
The default value is 100000 milliseconds.
Methods
Make()
Constructs a new ApocDriver and registers the newly created driver as the active driver.
Declaration
public static ApocDriver Make()
Returns
ApocDriver
An instance of ApocDriver |
Render(Stream, Stream)
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.
Declaration
public virtual void Render(Stream inputStream, Stream outputStream)
Parameters
System.IO.Stream
inputStream
Any subclass of the Stream class, e.g. FileStream |
System.IO.Stream
outputStream
Any subclass of the Stream class, e.g. FileStream |
Implements
Render(TextReader, Stream)
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.
Declaration
public virtual void Render(TextReader inputReader, Stream outputStream)
Parameters
System.IO.TextReader
inputReader
A character orientated stream |
System.IO.Stream
outputStream
Any subclass of the Stream class |
Implements
Render(String, 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.
Declaration
public virtual void Render(string inputFile, Stream outputStream)
Parameters
System.String
inputFile
Path to an XSL-FO file |
System.IO.Stream
outputStream
Any subclass of the Stream class, e.g. FileStream |
Implements
Render(String, String)
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.
Declaration
public virtual void Render(string inputFile, string outputFile)
Parameters
System.String
inputFile
Path to an XSL-FO file |
System.String
outputFile
Path to a file |
Implements
Remarks
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 System.IO.FileStream
for a complete list.
Render(XmlDocument, Stream)
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.
Declaration
public virtual void Render(XmlDocument doc, Stream outputStream)
Parameters
System.Xml.XmlDocument
doc
An in-memory representation of an XML document (DOM). |
System.IO.Stream
outputStream
Any subclass of the Stream class. |
Implements
Remarks
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 System.SystemException.
Render(XmlReader, Stream)
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.
Declaration
public void Render(XmlReader inputReader, Stream outputStream)
Parameters
System.Xml.XmlReader
inputReader
Reader that provides fast, non-cached, forward-only access to XML data |
System.IO.Stream
outputStream
Any subclass of the Stream class, e.g. FileStream |
Implements
Remarks
The evaluation copy of this class will output an evaluation banner to standard out
Events
OnError
A multicast delegate. The error event Apoc publishes.
Declaration
public event ApocDriver.ApocEventHandler OnError
Event Type
ApocDriver.ApocEventHandler
|
Remarks
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.
Examples
Subscribing to the 'error' event
[C#]
{ ApocDriver driver = ApocDriver.Make(); driver.OnError += new ApocDriver.ApocEventHandler(ApocError); ... }
OnInfo
A multicast delegate. The info event Apoc publishes.
Declaration
public event ApocDriver.ApocEventHandler OnInfo
Event Type
ApocDriver.ApocEventHandler
|
Remarks
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.
OnWarning
A multicast delegate. The warning event Apoc publishes.
Declaration
public event ApocDriver.ApocEventHandler OnWarning
Event Type
ApocDriver.ApocEventHandler
|
Remarks
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.