PoDoFo 0.9.20
Public Member Functions | Protected Member Functions | List of all members
PoDoFo::PdfDocument Class Referenceabstract

#include <PdfDocument.h>

Inheritance diagram for PoDoFo::PdfDocument:
PoDoFo::PdfMemDocument PoDoFo::PdfStreamedDocument

Public Member Functions

virtual ~PdfDocument ()
 
PdfOutlinesGetOrCreateOutlines ()
 
PdfNameTree & GetOrCreateNameTree ()
 
PdfAcroForm & GetOrCreateAcroForm (PdfAcroFormDefaulAppearance eDefaultAppearance=PdfAcroFormDefaulAppearance::BlackText12pt)
 
void AttachFile (const PdfFileSpec &fileSpec)
 
PdfFileSpecGetAttachment (const PdfString &name)
 
void AddNamedDestination (const PdfDestination &dest, const PdfString &name)
 
std::unique_ptr< PdfImageCreateImage (const std::string_view &prefix={ })
 
bool IsPrintAllowed () const
 
bool IsEditAllowed () const
 
bool IsCopyAllowed () const
 
bool IsEditNotesAllowed () const
 
bool IsFillAndSignAllowed () const
 
bool IsAccessibilityAllowed () const
 
bool IsDocAssemblyAllowed () const
 
bool IsHighPrintAllowed () const
 
bool IsEncrypted () const
 
PdfCatalog & GetCatalog ()
 
const PdfCatalog & GetCatalog () const
 
PdfPageCollectionGetPages ()
 
const PdfPageCollectionGetPages () const
 
PdfTrailer & GetTrailer ()
 
const PdfTrailer & GetTrailer () const
 
const PdfInfoGetInfo () const
 
PdfIndirectObjectListGetObjects ()
 
const PdfIndirectObjectListGetObjects () const
 

Protected Member Functions

 PdfDocument (bool empty=false)
 
void SetTrailer (std::unique_ptr< PdfObject > obj)
 
void Init ()
 
void Clear ()
 
virtual PdfVersion GetPdfVersion () const =0
 
virtual void SetPdfVersion (PdfVersion version)=0
 

Detailed Description

PdfDocument is the core interface for working with PDF documents.

PdfDocument provides easy access to the individual pages in the PDF file and to certain special dictionaries.

PdfDocument cannot be used directly. Use PdfMemDocument whenever you want to change the object structure of a PDF file.

When you are only creating PDF files, please use PdfStreamedDocument which is usually faster for creating PDFs.

See also
PdfStreamedDocument
PdfMemDocument

Constructor & Destructor Documentation

◆ ~PdfDocument()

PdfDocument::~PdfDocument ( )
virtual

Close down/destruct the PdfDocument

◆ PdfDocument()

PdfDocument::PdfDocument ( bool  empty = false)
protected

Construct a new (empty) PdfDocument

Parameters
emptyif true NO default objects (such as catalog) are created.

Member Function Documentation

◆ AddNamedDestination()

void PdfDocument::AddNamedDestination ( const PdfDestination dest,
const PdfString name 
)

Adds a PdfDestination into the global Names tree with the specified name, optionally replacing one of the same name.

Parameters
destthe destination to be assigned
namethe name for the destination

◆ AttachFile()

void PdfDocument::AttachFile ( const PdfFileSpec fileSpec)

Attach a file to the document.

Parameters
rFileSpeca file specification

◆ Clear()

void PdfDocument::Clear ( )
protected

Clear all internal variables and reset PdfDocument to an intial state.

◆ CreateImage()

unique_ptr< PdfImage > PdfDocument::CreateImage ( const std::string_view &  prefix = { })

Constuct a new PdfImage object

Parameters
prefixoptional prefix for XObject-name

◆ GetAttachment()

PdfFileSpec * PdfDocument::GetAttachment ( const PdfString name)

Get an attached file's filespec.

Parameters
namethe name of the attachment
Returns
the file specification object if the file exists, nullptr otherwise The file specification object is not owned by the document and must be deleted by the caller

◆ GetCatalog() [1/2]

PdfCatalog & PoDoFo::PdfDocument::GetCatalog ( )
inline

Get access to the internal Catalog dictionary or root object.

Returns
PdfObject the documents catalog

◆ GetCatalog() [2/2]

const PdfCatalog & PoDoFo::PdfDocument::GetCatalog ( ) const
inline

Get access to the internal Catalog dictionary or root object.

Returns
PdfObject the documents catalog

◆ GetInfo()

const PdfInfo * PoDoFo::PdfDocument::GetInfo ( ) const
inline

Get access to the internal Info dictionary You can set the author, title etc. of the document using the info dictionary.

Returns
the info dictionary

◆ GetObjects() [1/2]

PdfIndirectObjectList & PoDoFo::PdfDocument::GetObjects ( )
inline

Get access to the internal vector of objects or root object.

Returns
the vector of objects

◆ GetObjects() [2/2]

const PdfIndirectObjectList & PoDoFo::PdfDocument::GetObjects ( ) const
inline

Get access to the internal vector of objects or root object.

Returns
the vector of objects

◆ GetOrCreateAcroForm()

PdfAcroForm & PdfDocument::GetOrCreateAcroForm ( PdfAcroFormDefaulAppearance  eDefaultAppearance = PdfAcroFormDefaulAppearance::BlackText12pt)

Get access to the AcroForm dictionary

Parameters
createcreate the object if it does not exist (ePdfCreateObject) or return nullptr if it does not exist
eDefaultAppearancespecifies if a default appearence shall be created
Returns
PdfObject the AcroForm dictionary

◆ GetOrCreateNameTree()

PdfNameTree & PdfDocument::GetOrCreateNameTree ( )

Get access to the Names dictionary (where all the named objects are stored) The returned PdfNameTree object is owned by the PdfDocument.

Parameters
createcreate the object if it does not exist (ePdfCreateObject) or return nullptr if it does not exist
Returns
the Names dictionary

◆ GetOrCreateOutlines()

PdfOutlines & PdfDocument::GetOrCreateOutlines ( )

Get access to the Outlines (Bookmarks) dictionary The returned outlines object is owned by the PdfDocument.

Parameters
createcreate the object if it does not exist (ePdfCreateObject) or return nullptr if it does not exist
Returns
the Outlines/Bookmarks dictionary

◆ GetPages() [1/2]

PdfPageCollection & PoDoFo::PdfDocument::GetPages ( )
inline

Get access to the page tree.

Returns
the PdfPageTree of this document.

◆ GetPages() [2/2]

const PdfPageCollection & PoDoFo::PdfDocument::GetPages ( ) const
inline

Get access to the page tree.

Returns
the PdfPageTree of this document.

◆ GetPdfVersion()

virtual PdfVersion PoDoFo::PdfDocument::GetPdfVersion ( ) const
protectedpure virtual

Get the PDF version of the document

Returns
PdfVersion version of the pdf document

Implemented in PoDoFo::PdfMemDocument, and PoDoFo::PdfStreamedDocument.

◆ GetTrailer() [1/2]

PdfTrailer & PoDoFo::PdfDocument::GetTrailer ( )
inline

Get access to the internal trailer dictionary or root object.

Returns
PdfObject the documents catalog

◆ GetTrailer() [2/2]

const PdfTrailer & PoDoFo::PdfDocument::GetTrailer ( ) const
inline

Get access to the internal trailer dictionary or root object.

Returns
PdfObject the documents catalog

◆ Init()

void PdfDocument::Init ( )
protected

Internal method for initializing the pages tree for this document

◆ IsAccessibilityAllowed()

bool PdfDocument::IsAccessibilityAllowed ( ) const

Checks if it is allowed to extract text and graphics to support users with disabilities. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to extract text and graphics to support users with disabilities
See also
PdfEncrypt to set own document permissions.

◆ IsCopyAllowed()

bool PdfDocument::IsCopyAllowed ( ) const

Checks if text and graphics extraction is allowed. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to extract text and graphics from this document
See also
PdfEncrypt to set own document permissions.

◆ IsDocAssemblyAllowed()

bool PdfDocument::IsDocAssemblyAllowed ( ) const

Checks if it is allowed to insert, create, rotate, or delete pages or add bookmarks. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to insert, create, rotate, or delete pages or add bookmarks
See also
PdfEncrypt to set own document permissions.

◆ IsEditAllowed()

bool PdfDocument::IsEditAllowed ( ) const

Checks if modifying this document (besides annotations, form fields or substituting pages) is allowed. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to modify this document
See also
PdfEncrypt to set own document permissions.

◆ IsEditNotesAllowed()

bool PdfDocument::IsEditNotesAllowed ( ) const

Checks if it is allowed to add or modify annotations or form fields. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to add or modify annotations or form fields
See also
PdfEncrypt to set own document permissions.

◆ IsEncrypted()

bool PdfDocument::IsEncrypted ( ) const
Returns
true if this PdfMemDocument creates an encrypted PDF file

◆ IsFillAndSignAllowed()

bool PdfDocument::IsFillAndSignAllowed ( ) const

Checks if it is allowed to fill in existing form or signature fields. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to fill in existing form or signature fields
See also
PdfEncrypt to set own document permissions.

◆ IsHighPrintAllowed()

bool PdfDocument::IsHighPrintAllowed ( ) const

Checks if it is allowed to print a high quality version of this document Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to print a high quality version of this document
See also
PdfEncrypt to set own document permissions.

◆ IsPrintAllowed()

bool PdfDocument::IsPrintAllowed ( ) const

Checks if printing this document is allowed. Every PDF-consuming application has to adhere to this value!

Returns
true if you are allowed to print this document
See also
PdfEncrypt to set own document permissions.

◆ SetPdfVersion()

virtual void PoDoFo::PdfDocument::SetPdfVersion ( PdfVersion  version)
protectedpure virtual

Get the PDF version of the document

Returns
PdfVersion version of the pdf document

Implemented in PoDoFo::PdfMemDocument, and PoDoFo::PdfStreamedDocument.

◆ SetTrailer()

void PdfDocument::SetTrailer ( std::unique_ptr< PdfObject obj)
protected

Set the trailer of this PdfDocument deleting the old one.

Parameters
objthe new trailer object It will be owned by PdfDocument.