Skip to content

Extensibility

galkahana edited this page Sep 14, 2010 · 2 revisions

The library user might want to add PDF objects implementations, or to affect how the library functions.
The way to do that is to use DocumentContext and ObjectsContext classes directly, instead of through the facade provided by PDFWriter. The DocumentContext class implements complex objects such as pages, form XObject and Images. The ObjectsContext class implements the more basic building blocks, such as dictionaries, streams and primitive objects. You can get more information on the relation between these two objects in PDFWriter Project

There are 3 main methods to extend the library:

  1. Implement extender interfaces, and set them on either of the DocumentContext or ObjectsContext. Extenders control the way objects that are already implemented in the library gets written. Through an extender of a DocumentContext you can add keys to dictionary objects of Pages, the Catalog, Form XObjecte etc.
  2. Use the DocumentContext object to get such items as the Trailer object, or the trailer info and set values on them.
  3. Use the ObjectsContext object to write complex objects out of simpler, more primitive objects. Good examples on how to do this can be found in the DocumentContext implementations of form XObject and image XObject writing for JPG and Tiff Objects.

To read about all functionalities of these object read The DocumentContext Object and The ObjectsContext Object

Clone this wiki locally