PoDoFo 1.0.0-dev
|
PdfMemDocument is the core class for reading and manipulating PDF files and writing them back to disk. More...
#include <PdfMemDocument.h>
Public Member Functions | |
PdfMemDocument () | |
Construct a new PdfMemDocument. | |
PdfMemDocument (const std::shared_ptr< InputStreamDevice > &device, const std::string_view &password={ }) | |
PdfMemDocument (const PdfMemDocument &rhs) | |
Construct a copy of the given document. | |
void | Load (const std::string_view &filename, const std::string_view &password={ }) |
Load a PdfMemDocument from a file. | |
void | LoadFromBuffer (const bufferview &buffer, const std::string_view &password={ }) |
Load a PdfMemDocument from a buffer in memory. | |
void | Load (const std::shared_ptr< InputStreamDevice > &device, const std::string_view &password={ }) |
Load a PdfMemDocument from a PdfRefCountedInputDevice. | |
void | Save (const std::string_view &filename, PdfSaveOptions opts=PdfSaveOptions::None) |
Save the complete document to a file. | |
void | Save (OutputStreamDevice &device, PdfSaveOptions opts=PdfSaveOptions::None) |
Save the complete document to an output device. | |
void | SaveUpdate (const std::string_view &filename, PdfSaveOptions opts=PdfSaveOptions::None) |
Save the document changes to a file. | |
void | SaveUpdate (OutputStreamDevice &device, PdfSaveOptions opts=PdfSaveOptions::None) |
Save the document changes to an output device. | |
void | SetEncrypted (const std::string_view &userPassword, const std::string_view &ownerPassword, PdfPermissions protection=PdfPermissions::Default, PdfEncryptionAlgorithm algorithm=PdfEncryptionAlgorithm::AESV3R6, PdfKeyLength keyLength=PdfKeyLength::Unknown) |
Encrypt the document during writing. | |
void | SetEncrypt (std::unique_ptr< PdfEncrypt > &&encrypt) |
Encrypt the document during writing using a PdfEncrypt object. | |
const PdfEncrypt * | GetEncrypt () const override |
![]() | |
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. | |
PdfNameTrees & | GetOrCreateNames () |
Get access to the Names dictionary (where all the named objects are stored) The returned PdfNameTrees object is owned by the PdfDocument. | |
PdfAcroForm & | GetOrCreateAcroForm (PdfAcroFormDefaulAppearance eDefaultAppearance=PdfAcroFormDefaulAppearance::ArialBlack) |
Get access to the AcroForm dictionary. | |
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< PdfFunction > | CreateFunction (const PdfFunctionDefinitionPtr &definition) |
std::unique_ptr< PdfUncolouredTilingPattern > | CreateTilingPattern (const std::shared_ptr< PdfUncolouredTilingPatternDefinition > &definition) |
std::unique_ptr< PdfColouredTilingPattern > | CreateTilingPattern (const std::shared_ptr< PdfColouredTilingPatternDefinition > &definition) |
std::unique_ptr< PdfShadingPattern > | CreateShadingPattern (const PdfShadingPatternDefinitionPtr &definition) |
std::unique_ptr< PdfShadingDictionary > | CreateShadingDictionary (const PdfShadingDefinitionPtr &definition) |
std::unique_ptr< PdfExtGState > | CreateExtGState (const PdfExtGStateDefinitionPtr &definition) |
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. | |
bool | IsEditAllowed () const |
Checks if modifying this document (besides annotations, form fields or substituting pages) is allowed. | |
bool | IsCopyAllowed () const |
Checks if text and graphics extraction is allowed. | |
bool | IsEditNotesAllowed () const |
Checks if it is allowed to add or modify annotations or form fields. | |
bool | IsFillAndSignAllowed () const |
Checks if it is allowed to fill in existing form or signature fields. | |
bool | IsAccessibilityAllowed () const |
Checks if it is allowed to extract text and graphics to support users with disabilities. | |
bool | IsDocAssemblyAllowed () const |
Checks if it is allowed to insert, create, rotate, or delete pages or add bookmarks. | |
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! | |
void | PushPdfExtension (const PdfExtension &extension) |
Add a vendor-specific extension to the current PDF version. | |
bool | HasPdfExtension (const std::string_view &ns, int64_t level) const |
Checks whether the documents is tagged to imlpement a vendor-specific extension to the current PDF version. | |
void | RemovePdfExtension (const std::string_view &ns, int64_t level) |
Remove a vendor-specific extension to the current PDF version. | |
std::vector< PdfExtension > | GetPdfExtensions () const |
Return the list of all vendor-specific extensions to the current PDF version. | |
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. | |
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. | |
const PdfCatalog & | GetCatalog () const |
Get access to the internal Catalog dictionary or root object. | |
PdfPageCollection & | GetPages () |
Get access to the page tree. | |
const PdfPageCollection & | GetPages () const |
Get access to the page tree. | |
PdfTrailer & | GetTrailer () |
Get access to the internal trailer dictionary or root object. | |
const PdfTrailer & | GetTrailer () const |
Get access to the internal trailer dictionary or root object. | |
const PdfInfo * | GetInfo () const |
Get access to the internal Info dictionary You can set the author, title etc. | |
PdfMetadata & | GetMetadata () |
const PdfMetadata & | GetMetadata () const |
PdfIndirectObjectList & | GetObjects () |
Get access to the internal vector of objects or root object. | |
const PdfIndirectObjectList & | GetObjects () const |
Get access to the internal vector of objects or root object. | |
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 | |
void | SetPdfVersion (PdfVersion version) override |
Set the PDF Version of the document. | |
PdfVersion | GetPdfVersion () const override |
Get the PDF version of the document. | |
![]() | |
void | SetTrailer (std::unique_ptr< PdfObject > obj) |
Set the trailer of this PdfDocument deleting the old one. | |
void | Init () |
Internal method for initializing the pages tree for this document. | |
void | Clear () |
Clear all variables that have internal memory usage. | |
PdfMemDocument is the core class for reading and manipulating PDF files and writing them back to disk.
PdfMemDocument was designed to allow easy access to the object structure of a PDF file.
PdfMemDocument should be used whenever you want to change the object structure of a PDF file.
When you are only creating PDF files, please use PdfStreamedDocument which is usually faster for creating PDFs.
|
overridevirtual |
Implements PoDoFo::PdfDocument.
|
overrideprotectedvirtual |
Get the PDF version of the document.
Implements PoDoFo::PdfDocument.
void PoDoFo::PdfMemDocument::Load | ( | const std::shared_ptr< InputStreamDevice > & | device, |
const std::string_view & | password = { } |
||
) |
Load a PdfMemDocument from a PdfRefCountedInputDevice.
device | the input device containing the PDF |
void PoDoFo::PdfMemDocument::Load | ( | const std::string_view & | filename, |
const std::string_view & | password = { } |
||
) |
Load a PdfMemDocument from a file.
filename | filename of the file which is going to be parsed/opened |
When the bForUpdate is set to true, the filename is copied for later use by WriteUpdate.
void PdfMemDocument::LoadFromBuffer | ( | const bufferview & | buffer, |
const std::string_view & | password = { } |
||
) |
Load a PdfMemDocument from a buffer in memory.
buffer | a memory area containing the PDF data |
void PoDoFo::PdfMemDocument::Save | ( | const std::string_view & | filename, |
PdfSaveOptions | opts = PdfSaveOptions::None |
||
) |
Save the complete document to a file.
filename | filename of the document |
This is an overloaded member function for your convenience.
void PdfMemDocument::Save | ( | OutputStreamDevice & | device, |
PdfSaveOptions | opts = PdfSaveOptions::None |
||
) |
Save the complete document to an output device.
device | write to this output device |
void PoDoFo::PdfMemDocument::SaveUpdate | ( | const std::string_view & | filename, |
PdfSaveOptions | opts = PdfSaveOptions::None |
||
) |
Save the document changes to a file.
filename | filename of the document |
Writes the document changes to a file as an incremental update. The document should be loaded with bForUpdate = true, otherwise an exception is thrown.
Beware when overwriting existing files. Plain file overwrite is allowed only if the document was loaded with the same filename (and the same overloaded function), otherwise the destination file cannot be the same as the source file, because the destination file is truncated first and only then the source file content is copied into it.
This is an overloaded member function for your convenience.
void PdfMemDocument::SaveUpdate | ( | OutputStreamDevice & | device, |
PdfSaveOptions | opts = PdfSaveOptions::None |
||
) |
Save the document changes to an output device.
device | write to this output device |
Writes the document changes to the output device as an incremental update. The document should be loaded with bForUpdate = true, otherwise an exception is thrown.
void PdfMemDocument::SetEncrypt | ( | std::unique_ptr< PdfEncrypt > && | encrypt | ) |
Encrypt the document during writing using a PdfEncrypt object.
encrypt | an encryption object that will be owned by PdfMemDocument |
void PdfMemDocument::SetEncrypted | ( | const std::string_view & | userPassword, |
const std::string_view & | ownerPassword, | ||
PdfPermissions | protection = PdfPermissions::Default , |
||
PdfEncryptionAlgorithm | algorithm = PdfEncryptionAlgorithm::AESV3R6 , |
||
PdfKeyLength | keyLength = PdfKeyLength::Unknown |
||
) |
Encrypt the document during writing.
userPassword | the user password (if empty the user does not have to enter a password to open the document) |
ownerPassword | the owner password |
protection | several PdfPermissions values or'ed together to set the users permissions for this document |
algorithm | the revision of the encryption algorithm to be used |
keyLength | the length of the encryption key ranging from 40 to 256 bits (only used if algorithm >= PdfEncryptAlgorithm::RC4V2) |
|
overrideprotectedvirtual |
Set the PDF Version of the document.
Has to be called before Write() to have an effect.
version | version of the pdf document |
Implements PoDoFo::PdfDocument.