PoDoFo  1.0.0-dev
Public Member Functions | Protected Member Functions | Friends | List of all members
PoDoFo::PdfStreamedDocument Class Referencefinal

PdfStreamedDocument is the preferred class for creating new PDF documents. More...

#include <PdfStreamedDocument.h>

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

Public Member Functions

 PdfStreamedDocument (const std::shared_ptr< OutputStreamDevice > &device, PdfVersion version=PdfVersionDefault, const std::shared_ptr< PdfEncrypt > &encrypt=nullptr, PdfSaveOptions opts=PdfSaveOptions::None)
 Create a new PdfStreamedDocument. More...
 
 PdfStreamedDocument (const std::string_view &filename, PdfVersion version=PdfVersionDefault, const std::shared_ptr< PdfEncrypt > &encrypt=nullptr, PdfSaveOptions opts=PdfSaveOptions::None)
 Create a new PdfStreamedDocument. More...
 
const PdfEncryptGetEncrypt () const override
 
- Public Member Functions inherited from PoDoFo::PdfDocument
virtual ~PdfDocument ()
 Close down/destruct the PdfDocument.
 
PdfOutlinesGetOrCreateOutlines ()
 Get access to the Outlines (Bookmarks) dictionary The returned outlines object is owned by the PdfDocument. More...
 
PdfNameTreesGetOrCreateNames ()
 Get access to the Names dictionary (where all the named objects are stored) The returned PdfNameTrees object is owned by the PdfDocument. More...
 
PdfAcroForm & GetOrCreateAcroForm (PdfAcroFormDefaulAppearance eDefaultAppearance=PdfAcroFormDefaulAppearance::ArialBlack)
 Get access to the AcroForm dictionary. More...
 
void CollectGarbage ()
 
std::unique_ptr< PdfImageCreateImage ()
 Construct a new PdfImage object.
 
std::unique_ptr< PdfXObjectForm > CreateXObjectForm (const Rect &rect)
 
std::unique_ptr< PdfDestinationCreateDestination ()
 
std::unique_ptr< PdfColorSpace > CreateColorSpace (const PdfColorSpaceFilterPtr &filter)
 
std::unique_ptr< PdfExtGStateCreateExtGState ()
 
template<typename Taction >
std::unique_ptr< Taction > CreateAction ()
 
std::unique_ptr< PdfActionCreateAction (PdfActionType type)
 
std::unique_ptr< PdfFileSpecCreateFileSpec ()
 
bool IsPrintAllowed () const
 Checks if printing this document is allowed. More...
 
bool IsEditAllowed () const
 Checks if modifying this document (besides annotations, form fields or substituting pages) is allowed. More...
 
bool IsCopyAllowed () const
 Checks if text and graphics extraction is allowed. More...
 
bool IsEditNotesAllowed () const
 Checks if it is allowed to add or modify annotations or form fields. More...
 
bool IsFillAndSignAllowed () const
 Checks if it is allowed to fill in existing form or signature fields. More...
 
bool IsAccessibilityAllowed () const
 Checks if it is allowed to extract text and graphics to support users with disabilities. More...
 
bool IsDocAssemblyAllowed () const
 Checks if it is allowed to insert, create, rotate, or delete pages or add bookmarks. More...
 
bool 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! More...
 
PdfAcroForm & MustGetAcroForm ()
 
const PdfAcroForm & MustGetAcroForm () const
 
PdfNameTreesMustGetNames ()
 
const PdfNameTreesMustGetNames () const
 
PdfOutlinesMustGetOutlines ()
 
const PdfOutlinesMustGetOutlines () const
 
PdfDocumentFieldIterable GetFieldsIterator ()
 Get an iterator for all fields in the document. More...
 
PdfDocumentConstFieldIterable GetFieldsIterator () const
 
void Reset ()
 Clear all internal structures and reset PdfDocument to an empty state.
 
bool IsEncrypted () const
 
PdfCatalog & GetCatalog ()
 Get access to the internal Catalog dictionary or root object. More...
 
const PdfCatalog & GetCatalog () const
 Get access to the internal Catalog dictionary or root object. More...
 
PdfPageCollectionGetPages ()
 Get access to the page tree. More...
 
const PdfPageCollectionGetPages () const
 Get access to the page tree. More...
 
PdfTrailer & GetTrailer ()
 Get access to the internal trailer dictionary or root object. More...
 
const PdfTrailer & GetTrailer () const
 Get access to the internal trailer dictionary or root object. More...
 
const PdfInfoGetInfo () const
 Get access to the internal Info dictionary You can set the author, title etc. More...
 
PdfMetadata & GetMetadata ()
 
const PdfMetadata & GetMetadata () const
 
PdfIndirectObjectListGetObjects ()
 Get access to the internal vector of objects or root object. More...
 
const PdfIndirectObjectListGetObjects () const
 Get access to the internal vector of objects or root object. More...
 
PdfAcroForm * GetAcroForm ()
 
const PdfAcroForm * GetAcroForm () const
 
PdfNameTreesGetNames ()
 
const PdfNameTreesGetNames () const
 
PdfOutlinesGetOutlines ()
 
const PdfOutlinesGetOutlines () const
 
PdfFontManagerGetFonts ()
 
template<typename TAction >
std::unique_ptr< TAction > CreateAction ()
 

Protected Member Functions

PdfVersion GetPdfVersion () const override
 Get the PDF version of the document. More...
 
void SetPdfVersion (PdfVersion version) override
 Get the PDF version of the document. More...
 
- Protected Member Functions inherited from PoDoFo::PdfDocument
 PdfDocument (bool empty=false)
 Construct a new (empty) PdfDocument. More...
 
 PdfDocument (const PdfDocument &doc)
 
void SetTrailer (std::unique_ptr< PdfObject > obj)
 Set the trailer of this PdfDocument deleting the old one. More...
 
void Init ()
 Internal method for initializing the pages tree for this document.
 
virtual void reset ()
 
void Clear ()
 Clear all variables that have internal memory usage.
 
virtual void clear ()
 

Friends

class PdfImage
 

Detailed Description

PdfStreamedDocument is the preferred class for creating new PDF documents.

Page contents, fonts and images are written to disk as soon as possible and are not kept in memory. This results in faster document generation and less memory being used.

Please use PdfMemDocument if you intend to work on the object structure of a PDF file.

One of the design goals of PdfStreamedDocument was to hide the underlying object structure of a PDF file as far as possible.

See also
PdfDocument
PdfMemDocument

Example of using PdfStreamedDocument:

PdfStreamedDocument document("outputfile.pdf"); auto& page = document.GetPages().CreatePage(PdfPage::CreateStandardPageSize(PdfPageSize::A4)); auto* font = document.GetFonts().SearchFont("Arial");

PdfPainter painter; painter.SetCanvas(page); painter.TextState.SetFont(*font, 18); painter.DrawText("Hello World!", 56.69, page.GetRect().Height - 56.69); painter.FinishDrawing();

Constructor & Destructor Documentation

◆ PdfStreamedDocument() [1/2]

PoDoFo::PdfStreamedDocument::PdfStreamedDocument ( const std::shared_ptr< OutputStreamDevice > &  device,
PdfVersion  version = PdfVersionDefault,
const std::shared_ptr< PdfEncrypt > &  encrypt = nullptr,
PdfSaveOptions  opts = PdfSaveOptions::None 
)

Create a new PdfStreamedDocument.

All data is written to an output device immediately.

Parameters
devicean output device
versionthe PDF version of the document to write. The PDF version can only be set in the constructor as it is the first item written to the document on disk.
encryptpointer to an encryption object or nullptr. If not nullptr the PdfEncrypt object will be copied and used to encrypt the created document.
optsadditional save options for writing the pdf

◆ PdfStreamedDocument() [2/2]

PoDoFo::PdfStreamedDocument::PdfStreamedDocument ( const std::string_view &  filename,
PdfVersion  version = PdfVersionDefault,
const std::shared_ptr< PdfEncrypt > &  encrypt = nullptr,
PdfSaveOptions  opts = PdfSaveOptions::None 
)

Create a new PdfStreamedDocument.

All data is written to a file immediately.

Parameters
filenameresulting PDF file
versionthe PDF version of the document to write. The PDF version can only be set in the constructor as it is the first item written to the document on disk.
encryptpointer to an encryption object or nullptr. If not nullptr the PdfEncrypt object will be copied and used to encrypt the created document.
optsadditional options for writing the pdf

Member Function Documentation

◆ GetPdfVersion()

PdfVersion PdfStreamedDocument::GetPdfVersion ( ) const
overrideprotectedvirtual

Get the PDF version of the document.

Returns
PdfVersion version of the pdf document

Implements PoDoFo::PdfDocument.

◆ SetPdfVersion()

void PdfStreamedDocument::SetPdfVersion ( PdfVersion  version)
overrideprotectedvirtual

Get the PDF version of the document.

Returns
PdfVersion version of the pdf document

Implements PoDoFo::PdfDocument.


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