#include <flattener.h>
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 > |
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
| typedef std::vector<Ref> pdfobjects::utils::Flattener::RefList |
| virtual pdfobjects::utils::Flattener::~Flattener | ( | ) | [inline, private, virtual] |
| Flattener::Flattener | ( | FileStreamData & | streamData, | |
| IPdfWriter * | writer | |||
| ) | [protected] |
Referenced by getInstance().
| int Flattener::fillObjectList | ( | IPdfWriter::ObjectList & | objectList, | |
| int | maxObjectCount | |||
| ) | [protected, virtual] |
Fills up to given maxObjectCount into the given list.
| objectList | Container for objects. | |
| maxObjectCount | Maximum objects count to be filled. |
Note that given list is cleared at the beggining.
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.
| file | File handle where to put data. |
Delegates to PdfDocumentWriter::writeDocument(FILE*).
| 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.
| fileName | Output file name. |
Delegates to PdfDocumentWriter::writeDocument(const char*).
| 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.
| fileName | Input PDF document. | |
| pdfWriter | PDF Writer to be used for content writing. |
| MalformedFormatExeption | if file content is not valid pdf document. |
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().
friend class FileStreamDataDeleter< Flattener > [friend] |
size_t pdfobjects::utils::Flattener::lastIndex [private] |
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().