PoDoFo 0.9.20
PoDoFo::PdfStreamedDocument Class Referencefinal

#include <PdfStreamedDocument.h>

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

Public Member Functions

 PdfStreamedDocument (const std::shared_ptr< OutputStreamDevice > &device, PdfVersion version=PdfVersionDefault, PdfEncrypt *encrypt=nullptr, PdfSaveOptions opts=PdfSaveOptions::None)
 
 PdfStreamedDocument (const std::string_view &filename, PdfVersion version=PdfVersionDefault, PdfEncrypt *encrypt=nullptr, PdfSaveOptions opts=PdfSaveOptions::None)
 
void Close ()
 
- Public Member Functions inherited from PoDoFo::PdfDocument
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

PdfVersion GetPdfVersion () const override
 
void SetPdfVersion (PdfVersion version) override
 
- Protected Member Functions inherited from PoDoFo::PdfDocument
 PdfDocument (bool empty=false)
 
void SetTrailer (std::unique_ptr< PdfObject > obj)
 
void Init ()
 
void Clear ()
 

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; document.Load("outputfile.pdf"); PdfPage& page = document.GetPages().CreatePage(PdfPage::CreateStandardPageSize(PdfPageSize::A4)); PdfFont* 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]

PdfStreamedDocument::PdfStreamedDocument ( const std::shared_ptr< OutputStreamDevice > & device,
PdfVersion version = PdfVersionDefault,
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,
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

◆ Close()

void PdfStreamedDocument::Close ( )

Close the document. The PDF file on disk is finished. No other member function of this class may be called after calling this function.

◆ 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.