pdfmm 0.9.20
Public Member Functions | List of all members
mm::PdfStreamedDocument Class Reference

#include <PdfStreamedDocument.h>

Inheritance diagram for mm::PdfStreamedDocument:
mm::PdfDocument

Public Member Functions

 PdfStreamedDocument (PdfOutputDevice &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 ()
 
PdfVersion GetPdfVersion () const override
 
bool IsLinearized () const override
 
bool IsPrintAllowed () const override
 
bool IsEditAllowed () const override
 
bool IsCopyAllowed () const override
 
bool IsEditNotesAllowed () const override
 
bool IsFillAndSignAllowed () const override
 
bool IsAccessibilityAllowed () const override
 
bool IsDocAssemblyAllowed () const override
 
bool IsHighPrintAllowed () const override
 
- Public Member Functions inherited from mm::PdfDocument
virtual ~PdfDocument ()
 
virtual PdfVersion GetPdfVersion () const =0
 
virtual bool IsLinearized () const =0
 
PdfOutlinesGetOrCreateOutlines ()
 
PdfNameTree & GetOrCreateNameTree ()
 
PdfAcroForm & GetOrCreateAcroForm (PdfAcroFormDefaulAppearance eDefaultAppearance=PdfAcroFormDefaulAppearance::BlackText12pt)
 
void EmbedSubsetFonts ()
 
const PdfDocumentAppend (const PdfDocument &doc, bool appendAll=true)
 
const PdfDocumentInsertExistingPageAt (const PdfDocument &doc, unsigned pageIndex, unsigned atIndex)
 
PdfRect FillXObjectFromDocumentPage (PdfXObject &xobj, const PdfDocument &doc, unsigned pageIndex, bool useTrimBox)
 
PdfRect FillXObjectFromExistingPage (PdfXObject &xobj, unsigned pageIndex, bool useTrimBox)
 
PdfRect FillXObjectFromPage (PdfXObject &xobj, const PdfPage &page, bool useTrimBox, unsigned difference)
 
void AttachFile (const PdfFileSpec &fileSpec)
 
PdfFileSpecGetAttachment (const PdfString &name)
 
void AddNamedDestination (const PdfDestination &dest, const PdfString &name)
 
void SetPageMode (PdfPageMode inMode)
 
PdfPageMode GetPageMode () const
 
void SetUseFullScreen ()
 
void SetPageLayout (PdfPageLayout inLayout)
 
void SetHideToolbar ()
 
void SetHideMenubar ()
 
void SetHideWindowUI ()
 
void SetFitWindow ()
 
void SetCenterWindow ()
 
void SetDisplayDocTitle ()
 
void SetPrintScaling (const PdfName &scalingType)
 
void SetBaseURI (const std::string_view &baseURI)
 
void SetLanguage (const std::string_view &language)
 
void SetBindingDirection (const PdfName &direction)
 
virtual bool IsPrintAllowed () const =0
 
virtual bool IsEditAllowed () const =0
 
virtual bool IsCopyAllowed () const =0
 
virtual bool IsEditNotesAllowed () const =0
 
virtual bool IsFillAndSignAllowed () const =0
 
virtual bool IsAccessibilityAllowed () const =0
 
virtual bool IsDocAssemblyAllowed () const =0
 
virtual bool IsHighPrintAllowed () const =0
 
PdfObjectGetCatalog ()
 
const PdfObjectGetCatalog () const
 
PdfPageTreeGetPageTree ()
 
const PdfPageTreeGetPageTree () const
 
PdfObjectGetTrailer ()
 
const PdfObjectGetTrailer () const
 
PdfInfoGetInfo ()
 
const PdfInfoGetInfo () const
 
PdfIndirectObjectListGetObjects ()
 
const PdfIndirectObjectListGetObjects () const
 
PdfObjectGetStructTreeRoot ()
 
PdfObjectGetMetadata ()
 
PdfObjectGetMarkInfo ()
 
PdfObjectGetLanguage ()
 

Additional Inherited Members

- Protected Member Functions inherited from mm::PdfDocument
 PdfDocument (bool empty=false)
 
void SetTrailer (std::unique_ptr< PdfObject > obj)
 
void Init ()
 
void FixObjectReferences (PdfObject &obj, int difference)
 
void SetViewerPreference (const PdfName &whichPref, const PdfObject &valueObj)
 
void SetViewerPreference (const PdfName &whichPref, bool inValue)
 
void Clear ()
 
PdfObjectgetCatalog ()
 

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"); PdfPage* page = document.CreatePage(PdfPage::CreateStandardPageSize(PdfPageSize::A4)); PdfFont* font = document.CreateFont("Arial");

PdfPainter painter; painter.SetPage(page); painter.SetFont(font); painter.DrawText(56.69, page->GetRect().GetHeight() - 56.69, "Hello World!"); painter.FinishPage();

document.Close();

Constructor & Destructor Documentation

◆ PdfStreamedDocument() [1/2]

PdfStreamedDocument::PdfStreamedDocument ( PdfOutputDevice 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]

mm::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 maybe called after calling this function.

◆ GetPdfVersion()

PdfVersion PdfStreamedDocument::GetPdfVersion ( ) const
overridevirtual

Get the PDF version of the document

Returns
PdfVersion version of the pdf document

Implements mm::PdfDocument.

◆ IsAccessibilityAllowed()

bool PdfStreamedDocument::IsAccessibilityAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsCopyAllowed()

bool PdfStreamedDocument::IsCopyAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsDocAssemblyAllowed()

bool PdfStreamedDocument::IsDocAssemblyAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsEditAllowed()

bool PdfStreamedDocument::IsEditAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsEditNotesAllowed()

bool PdfStreamedDocument::IsEditNotesAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsFillAndSignAllowed()

bool PdfStreamedDocument::IsFillAndSignAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsHighPrintAllowed()

bool PdfStreamedDocument::IsHighPrintAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.

◆ IsLinearized()

bool PdfStreamedDocument::IsLinearized ( ) const
overridevirtual

Returns whether this PDF document is linearized, aka web-optimized

Returns
true if the PDF document is linearized

Implements mm::PdfDocument.

◆ IsPrintAllowed()

bool PdfStreamedDocument::IsPrintAllowed ( ) const
overridevirtual

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.

Implements mm::PdfDocument.