skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • AI Coding Assistants
    • Embedded Reporting
    • Document Processing Libraries
    • SSO Account Sign-in

    Web

    Kendo UI UI for Angular UI for Vue UI for jQuery KendoReact UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX

    Mobile

    UI for .NET MAUI

    Document Management

    Telerik Document Processing

    Desktop

    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF

    Reporting

    Telerik Reporting Telerik Report Server

    Testing & Mocking

    Test Studio Telerik JustMock

    CMS

    Sitefinity

    AI Productivity Tools

    AI Coding Assistants

    UI/UX Tools

    ThemeBuilder Design System Kit Templates and Building Blocks

    Debugging

    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Everywhere Reporter FiddlerCore

    Free Tools

    KendoReact Free VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Support and Learning

    • Support and Learning Hub
    • First Steps
    • Docs
    • Demos
    • Virtual Classroom
    • Forums
    • Videos
    • Blogs
    • Accessibility
    • Submit a Ticket

    Productivity and Design Tools

    • Visual Studio Extensions
    • Visual Studio Templates
    • Embedded Reporting
  • Pricing
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class ApocDriver

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

Inheritance
System.Object
ApocDriver
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
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
IDriver.BaseDirectory

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
IDriver.CloseOnExit

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
IDriver.Credentials
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
IDriver.Options
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
IDriver.Renderer
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
IDriver.Timeout
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
IDriver.Render(Stream, Stream)

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
IDriver.Render(TextReader, Stream)

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
IDriver.Render(String, Stream)

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
IDriver.Render(String, String)
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
IDriver.Render(XmlDocument, Stream)
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
IDriver.Render(XmlReader, Stream)
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.

Extension Methods

SvgExtentions.Traverse<T>(T, Func<T, IEnumerable<T>>)
SvgExtentions.TraverseDepthFirst<T>(T, Func<T, IEnumerable<T>>)
Getting Started
  • Install Now
  • Demos
  • Step-by-Step Tutorial
  • Sample Applications
  • SDK Samples
  • Visual Studio Extensions
Support Resources
  • Code Library
  • Knowledge Base
  • Videos
Community
  • Forums
  • Blogs
  • Feedback Portal
  • Document Processing Feedback Portal

Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.