PoDoFo
1.0.0-dev
|
PdfStreamedDocument is the preferred class for creating new PDF documents. More...
#include <PdfStreamedDocument.h>
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 PdfEncrypt * | GetEncrypt () const override |
Public Member Functions inherited from PoDoFo::PdfDocument | |
virtual | ~PdfDocument () |
Close down/destruct the PdfDocument. | |
PdfOutlines & | GetOrCreateOutlines () |
Get access to the Outlines (Bookmarks) dictionary The returned outlines object is owned by the PdfDocument. More... | |
PdfNameTrees & | GetOrCreateNames () |
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< PdfImage > | CreateImage () |
Construct a new PdfImage object. | |
std::unique_ptr< PdfXObjectForm > | CreateXObjectForm (const Rect &rect) |
std::unique_ptr< PdfDestination > | CreateDestination () |
std::unique_ptr< PdfColorSpace > | CreateColorSpace (const PdfColorSpaceFilterPtr &filter) |
std::unique_ptr< PdfExtGState > | CreateExtGState () |
template<typename Taction > | |
std::unique_ptr< Taction > | CreateAction () |
std::unique_ptr< PdfAction > | CreateAction (PdfActionType type) |
std::unique_ptr< PdfFileSpec > | CreateFileSpec () |
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 |
PdfNameTrees & | MustGetNames () |
const PdfNameTrees & | MustGetNames () const |
PdfOutlines & | MustGetOutlines () |
const PdfOutlines & | MustGetOutlines () 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... | |
PdfPageCollection & | GetPages () |
Get access to the page tree. More... | |
const PdfPageCollection & | GetPages () 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 PdfInfo * | GetInfo () const |
Get access to the internal Info dictionary You can set the author, title etc. More... | |
PdfMetadata & | GetMetadata () |
const PdfMetadata & | GetMetadata () const |
PdfIndirectObjectList & | GetObjects () |
Get access to the internal vector of objects or root object. More... | |
const PdfIndirectObjectList & | GetObjects () const |
Get access to the internal vector of objects or root object. More... | |
PdfAcroForm * | GetAcroForm () |
const PdfAcroForm * | GetAcroForm () const |
PdfNameTrees * | GetNames () |
const PdfNameTrees * | GetNames () const |
PdfOutlines * | GetOutlines () |
const PdfOutlines * | GetOutlines () const |
PdfFontManager & | GetFonts () |
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 |
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.
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();
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.
device | an output device |
version | the 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. |
encrypt | pointer to an encryption object or nullptr. If not nullptr the PdfEncrypt object will be copied and used to encrypt the created document. |
opts | additional save options for writing the pdf |
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.
filename | resulting PDF file |
version | the 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. |
encrypt | pointer to an encryption object or nullptr. If not nullptr the PdfEncrypt object will be copied and used to encrypt the created document. |
opts | additional options for writing the pdf |
|
overrideprotectedvirtual |
Get the PDF version of the document.
Implements PoDoFo::PdfDocument.
|
overrideprotectedvirtual |
Get the PDF version of the document.
Implements PoDoFo::PdfDocument.