PoDoFo 0.9.20
|
#include <PdfMemDocument.h>
Public Member Functions | |
PdfMemDocument () | |
PdfMemDocument (const PdfMemDocument &rhs) | |
void | Load (const std::string_view &filename, const std::string_view &password={ }) |
void | LoadFromBuffer (const bufferview &buffer, const std::string_view &password={ }) |
void | LoadFromDevice (const std::shared_ptr< InputStreamDevice > &device, const std::string_view &password={ }) |
void | Save (const std::string_view &filename, PdfSaveOptions opts=PdfSaveOptions::None) |
void | Save (OutputStreamDevice &device, PdfSaveOptions opts=PdfSaveOptions::None) |
void | SaveUpdate (const std::string_view &filename, PdfSaveOptions opts=PdfSaveOptions::None) |
void | SaveUpdate (OutputStreamDevice &device, PdfSaveOptions opts=PdfSaveOptions::None) |
void | AddPdfExtension (const PdfName &ns, int64_t level) |
bool | HasPdfExtension (const PdfName &ns, int64_t level) const |
void | RemovePdfExtension (const PdfName &ns, int64_t level) |
std::vector< PdfExtension > | GetPdfExtensions () const |
void | SetEncrypted (const std::string_view &userPassword, const std::string_view &ownerPassword, PdfPermissions protection=PdfPermissions::Default, PdfEncryptAlgorithm algorithm=PdfEncryptAlgorithm::AESV2, PdfKeyLength keyLength=PdfKeyLength::L40) |
void | SetEncrypt (std::unique_ptr< PdfEncrypt > &&encrypt) |
void | FreeObjectMemory (const PdfReference &ref, bool force=false) |
void | FreeObjectMemory (PdfObject *obj, bool force=false) |
![]() | |
virtual | ~PdfDocument () |
PdfOutlines & | GetOrCreateOutlines () |
PdfNameTree & | GetOrCreateNameTree () |
PdfAcroForm & | GetOrCreateAcroForm (PdfAcroFormDefaulAppearance eDefaultAppearance=PdfAcroFormDefaulAppearance::BlackText12pt) |
void | AttachFile (const PdfFileSpec &fileSpec) |
PdfFileSpec * | GetAttachment (const PdfString &name) |
void | AddNamedDestination (const PdfDestination &dest, const PdfString &name) |
std::unique_ptr< PdfImage > | CreateImage (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 |
PdfPageCollection & | GetPages () |
const PdfPageCollection & | GetPages () const |
PdfTrailer & | GetTrailer () |
const PdfTrailer & | GetTrailer () const |
const PdfInfo * | GetInfo () const |
PdfIndirectObjectList & | GetObjects () |
const PdfIndirectObjectList & | GetObjects () const |
Protected Member Functions | |
void | SetPdfVersion (PdfVersion version) override |
PdfVersion | GetPdfVersion () const override |
![]() | |
PdfDocument (bool empty=false) | |
void | SetTrailer (std::unique_ptr< PdfObject > obj) |
void | Init () |
void | Clear () |
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 structur 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.
PdfMemDocument::PdfMemDocument | ( | ) |
Construct a new PdfMemDocument
PdfMemDocument::PdfMemDocument | ( | const PdfMemDocument & | rhs | ) |
Construct a copy of the given document
void PdfMemDocument::AddPdfExtension | ( | const PdfName & | ns, |
int64_t | level | ||
) |
Add a vendor-specific extension to the current PDF version.
ns | namespace of the extension |
level | level of the extension |
void PdfMemDocument::FreeObjectMemory | ( | const PdfReference & | ref, |
bool | force = false |
||
) |
Tries to free all memory allocated by the given PdfObject (variables and streams) and reads it from disk again if it is requested another time.
This will only work if load on demand is used. Other- wise any call to this method will be ignored. Load on demand is currently always enabled when using PdfMemDocument. If the object is dirty if will not be free'd.
ref | free all memory allocated by the object with this reference. |
force | if true the object will be free'd even if IsDirty() returns true. So you will loose any changes made to this object. |
This is an overloaded member for your convenience.
void PdfMemDocument::FreeObjectMemory | ( | PdfObject * | obj, |
bool | force = false |
||
) |
Tries to free all memory allocated by the given PdfObject (variables and streams) and reads it from disk again if it is requested another time.
This will only work if load on demand is used. Other- wise any call to this method will be ignored. Load on demand is currently always enabled when using PdfMemDocument. If the object is dirty if will not be free'd.
obj | free object from memory |
force | if true the object will be free'd even if IsDirty() returns true. So you will loose any changes made to this object. |
vector< PdfExtension > PdfMemDocument::GetPdfExtensions | ( | ) | const |
Return the list of all vendor-specific extensions to the current PDF version.
ns | namespace of the extension |
level | level of the extension |
|
overrideprotectedvirtual |
Get the PDF version of the document
Implements PoDoFo::PdfDocument.
bool PdfMemDocument::HasPdfExtension | ( | const PdfName & | ns, |
int64_t | level | ||
) | const |
Checks whether the documents is tagged to imlpement a vendor-specific extension to the current PDF version.
ns | namespace of the extension |
level | level of the extension |
void 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 PdfMemDocument::LoadFromDevice | ( | 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 PdfMemDocument::RemovePdfExtension | ( | const PdfName & | ns, |
int64_t | level | ||
) |
Remove a vendor-specific extension to the current PDF version.
ns | namespace of the extension |
level | level of the extension |
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 , |
||
PdfEncryptAlgorithm | algorithm = PdfEncryptAlgorithm::AESV2 , |
||
PdfKeyLength | keyLength = PdfKeyLength::L40 |
||
) |
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.