pdfobjects::utils::Flattener Class Reference

#include <flattener.h>

Inheritance diagram for pdfobjects::utils::Flattener:
pdfobjects::utils::PdfDocumentWriter pdfobjects::CXref

List of all members.

Public Types

typedef std::vector< Ref > RefList

Public Member Functions

int flatten (const char *fileName)
int flatten (FILE *file)

Static Public Member Functions

static boost::shared_ptr
< Flattener
getInstance (const char *fileName, IPdfWriter *pdfWriter)

Public Attributes

RefList reachAbleRefs

Protected Member Functions

 Flattener (FileStreamData &streamData, IPdfWriter *writer)
void initReachableObjects ()
virtual int fillObjectList (IPdfWriter::ObjectList &objectList, int maxObjectCount)

Private Member Functions

virtual ~Flattener ()

Private Attributes

size_t lastIndex

Friends

class FileStreamDataDeleter< Flattener >

Detailed Description

Flattener class. Provides functionality to write the new PDF document with the all reachable objects from the original document in the single revision.
This can be usefull for several reasons:

Usage Use static factory method for instance creation:

 // we will use OldStylePdfWriter IPdfWriter implementator
 IPdfWriter * contentWriter=new OldStylePdfWriter();
 boost::shared_ptr<Flattener> flattener = Flattener::getInstance(fileName, contentWriter);
 // check for encryption and set credentials if necessary
 if (flattener->isEncrypted())
 	flattener->setCredentials(ownerPasswd, userPasswd);
 // flatten file content to the file specified by name
 flattener->delinearize(outputFile);
 ...
 // instance is wrapped by the smart pointer so you don't
 // have bother with deallocation
 

Member Typedef Documentation

typedef std::vector<Ref> pdfobjects::utils::Flattener::RefList

Constructor & Destructor Documentation

virtual pdfobjects::utils::Flattener::~Flattener (  )  [inline, private, virtual]
Flattener::Flattener ( FileStreamData streamData,
IPdfWriter writer 
) [protected]

Referenced by getInstance().


Member Function Documentation

int Flattener::fillObjectList ( IPdfWriter::ObjectList objectList,
int  maxObjectCount 
) [protected, virtual]

Fills up to given maxObjectCount into the given list.

Parameters:
objectList Container for objects.
maxObjectCount Maximum objects count to be filled.

Note that given list is cleared at the beggining.

Returns:
number of objects filled into the container.

Implements pdfobjects::utils::PdfDocumentWriter.

References debug::DBG_DBG, debug::DBG_ERR, pdfobjects::CXref::fetch(), xpdf::freeXpdfObject(), getInstance(), kernelPrintDbg, lastIndex, reachAbleRefs, and utilsPrintDbg.

int Flattener::flatten ( FILE *  file  ) 

Flattens this document and puts the result into the given file.

Parameters:
file File handle where to put data.

Delegates to PdfDocumentWriter::writeDocument(FILE*).

Exceptions:
NotImplementedException if document is encrypted.
MalformedFormatExeption if the input file is currupted.

References initReachableObjects(), and pdfobjects::utils::PdfDocumentWriter::writeDocument().

int Flattener::flatten ( const char *  fileName  ) 

Flattens this document and puts the result into the given file.

Parameters:
fileName Output file name.

Delegates to PdfDocumentWriter::writeDocument(const char*).

Returns:
0 on success, errno otherwise.
Exceptions:
NotImplementedException if document is encrypted.
MalformedFormatExeption if the input file is currupted.

References initReachableObjects(), and pdfobjects::utils::PdfDocumentWriter::writeDocument().

boost::shared_ptr< Flattener > Flattener::getInstance ( const char *  fileName,
IPdfWriter pdfWriter 
) [static]

Factory method.

Parameters:
fileName Input PDF document.
pdfWriter PDF Writer to be used for content writing.
Exceptions:
MalformedFormatExeption if file content is not valid pdf document.
Returns:
Instance ready to be used.

References debug::DBG_ERR, Flattener(), pdfobjects::utils::PdfDocumentWriter::getStreamData(), and utilsPrintDbg.

Referenced by fillObjectList().

void Flattener::initReachableObjects (  )  [protected]

Initializes all reachable objects.

Starts with the Trailer and recursively travels all reachable indirect objects which are stored in reachAbleRefs container.

References debug::DBG_DBG, debug::DBG_INFO, pdfobjects::CXref::getTrailerDict(), lastIndex, reachAbleRefs, and utilsPrintDbg.

Referenced by flatten().


Friends And Related Function Documentation

friend class FileStreamDataDeleter< Flattener > [friend]

Member Data Documentation

Index of the last in the reachAbleRefs returned object by fillObjectList. Zeroed in flatten methods.

Referenced by fillObjectList(), and initReachableObjects().

List of all reachable indirect objects. Initialized in initReachableObjects.

Referenced by fillObjectList(), and initReachableObjects().


The documentation for this class was generated from the following files: