PoDoFo 0.9.20
Public Member Functions | Protected Member Functions | List of all members
PoDoFo::PdfWriter Class Reference

#include <PdfWriter.h>

Inheritance diagram for PoDoFo::PdfWriter:
PoDoFo::PdfImmediateWriter

Public Member Functions

 PdfWriter (PdfIndirectObjectList &objects, const PdfObject &trailer)
 
void Write (OutputStreamDevice &device)
 
void SetUseXRefStream (bool useXRefStream)
 
void SetEncrypt (const PdfEncrypt &encrypt)
 
void FillTrailerObject (PdfObject &trailer, size_t size, bool onlySizeKey) const
 
PdfWriteFlags GetWriteFlags () const
 
void SetPdfVersion (PdfVersion version)
 
PdfVersion GetPdfVersion () const
 
bool GetUseXRefStream () const
 
void SetPrevXRefOffset (int64_t prevXRefOffset)
 
int64_t GetPrevXRefOffset () const
 
void SetIncrementalUpdate (bool rewriteXRefTable)
 
bool GetIncrementalUpdate () const
 
bool GetEncrypted () const
 

Protected Member Functions

 PdfWriter (PdfIndirectObjectList &objects)
 
void WritePdfHeader (OutputStreamDevice &device)
 
void WritePdfObjects (OutputStreamDevice &device, const PdfIndirectObjectList &objects, PdfXRef &xref)
 
void CreateFileIdentifier (PdfString &identifier, const PdfObject &trailer, PdfString *originalIdentifier=nullptr)
 

Detailed Description

The PdfWriter class writes a list of PdfObjects as PDF file. The XRef section (which is the required table of contents for any PDF file) is created automatically.

It does not know about pages but only about PdfObjects.

Most users will want to use PdfDocument.

Constructor & Destructor Documentation

◆ PdfWriter() [1/2]

PdfWriter::PdfWriter ( PdfIndirectObjectList objects,
const PdfObject trailer 
)

Create a new pdf file, from an vector of PdfObjects and a trailer object.

Parameters
objectsthe vector of objects
trailera valid trailer object

◆ PdfWriter() [2/2]

PdfWriter::PdfWriter ( PdfIndirectObjectList objects)
protected

Member Function Documentation

◆ CreateFileIdentifier()

void PdfWriter::CreateFileIdentifier ( PdfString identifier,
const PdfObject trailer,
PdfString originalIdentifier = nullptr 
)
protected

Creates a file identifier which is required in several PDF workflows. All values from the files document information dictionary are used to create a unique MD5 key which is added to the trailer dictionary.

Parameters
identifierwrite the identifier to this string
trailertrailer object
pOriginalIdentifierwrite the original identifier (when using incremental update) to this string

◆ FillTrailerObject()

void PdfWriter::FillTrailerObject ( PdfObject trailer,
size_t  size,
bool  onlySizeKey 
) const

Add required keys to a trailer object

Parameters
traileradd keys to this object
sizenumber of objects in the PDF file
onlySizeKeywrite only the size key

◆ GetEncrypted()

bool PoDoFo::PdfWriter::GetEncrypted ( ) const
inline
Returns
true if this PdfWriter creates an encrypted PDF file

◆ GetIncrementalUpdate()

bool PoDoFo::PdfWriter::GetIncrementalUpdate ( ) const
inline
Returns
whether writing an incremental update

◆ GetPdfVersion()

PdfVersion PoDoFo::PdfWriter::GetPdfVersion ( ) const
inline

Get the PDF version of the document

Returns
PdfVersion version of the pdf document

◆ GetPrevXRefOffset()

int64_t PoDoFo::PdfWriter::GetPrevXRefOffset ( ) const
inline
Returns
offset to the previous XRef table, as previously set by SetPrevXRefOffset.
See also
SetPrevXRefOffset

◆ GetUseXRefStream()

bool PoDoFo::PdfWriter::GetUseXRefStream ( ) const
inline
Returns
whether an XRef stream is used or not

◆ GetWriteFlags()

PdfWriteFlags PoDoFo::PdfWriter::GetWriteFlags ( ) const
inline

Get the write mode used for writing the PDF

Returns
the write mode

◆ SetEncrypt()

void PdfWriter::SetEncrypt ( const PdfEncrypt encrypt)

Set the written document to be encrypted using a PdfEncrypt object

Parameters
encryptan encryption object which is used to encrypt the written PDF file

◆ SetIncrementalUpdate()

void PdfWriter::SetIncrementalUpdate ( bool  rewriteXRefTable)

Set whether writing an incremental update. Default is false.

Parameters
incrementalUpdateif true an incremental update will be written

◆ SetPdfVersion()

void PoDoFo::PdfWriter::SetPdfVersion ( PdfVersion  version)
inline

Set the PDF Version of the document. Has to be called before Write() to have an effect.

Parameters
versionversion of the pdf document

◆ SetPrevXRefOffset()

void PoDoFo::PdfWriter::SetPrevXRefOffset ( int64_t  prevXRefOffset)
inline

Sets an offset to the previous XRef table. Set it to lower than or equal to 0, to not write a reference to the previous XRef table. The default is 0.

Parameters
lPrevXRefOffsetthe previous XRef table offset

◆ SetUseXRefStream()

void PdfWriter::SetUseXRefStream ( bool  useXRefStream)

Create a XRef stream which is in some case more compact but requires at least PDF 1.5 Default is false.

Parameters
useXRefStreamif true a XRef stream object will be created

◆ Write()

void PdfWriter::Write ( OutputStreamDevice &  device)

Internal implementation of the Write() call with the common code

Parameters
devicewrite to this output device
bRewriteXRefTablewhether will rewrite whole XRef table (used only if GetIncrementalUpdate() returns true)

◆ WritePdfHeader()

void PdfWriter::WritePdfHeader ( OutputStreamDevice &  device)
protected

Writes the pdf header to the current file.

Parameters
devicewrite to this output device

◆ WritePdfObjects()

void PdfWriter::WritePdfObjects ( OutputStreamDevice &  device,
const PdfIndirectObjectList objects,
PdfXRef xref 
)
protected

Write pdf objects to file

Parameters
devicewrite to this output device
objectswrite all objects in this vector to the file
pXrefadd all written objects to this XRefTable
bRewriteXRefTablewhether will rewrite whole XRef table (used only if GetIncrementalUpdate() returns true)