|
pdfmm 0.9.20
|
#include <PdfMemDocument.h>
Public Member Functions | |
| PdfMemDocument (bool empty=false) | |
| PdfMemDocument (const PdfMemDocument &rhs) | |
| void | Load (const std::string_view &filename, const std::string_view &password={ }) |
| void | LoadFromBuffer (const std::string_view &buffer, const std::string_view &password={ }) |
| void | LoadFromDevice (const std::shared_ptr< PdfInputDevice > &device, const std::string_view &password={ }) |
| void | Write (const std::string_view &filename, PdfSaveOptions opts=PdfSaveOptions::None) |
| void | Write (PdfOutputDevice &device, PdfSaveOptions opts=PdfSaveOptions::None) |
| void | WriteUpdate (const std::string_view &filename, PdfSaveOptions opts=PdfSaveOptions::None) |
| void | WriteUpdate (PdfOutputDevice &device, PdfSaveOptions opts=PdfSaveOptions::None) |
| void | SetPdfVersion (PdfVersion version) |
| PdfVersion | GetPdfVersion () const override |
| 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 &userPassword, const std::string &ownerPassword, PdfPermissions protection=PdfPermissions::Default, PdfEncryptAlgorithm algorithm=PdfEncryptAlgorithm::AESV2, PdfKeyLength keyLength=PdfKeyLength::L40) |
| void | SetEncrypted (const PdfEncrypt &encrypt) |
| bool | IsEncrypted () const |
| bool | IsLinearized () const override |
| const PdfMemDocument & | InsertPages (const PdfMemDocument &doc, unsigned atIndex, unsigned pageCount) |
| 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 |
| void | FreeObjectMemory (const PdfReference &ref, bool force=false) |
| void | FreeObjectMemory (PdfObject *obj, bool force=false) |
| const PdfEncrypt * | GetEncrypt () const |
Public Member Functions inherited from mm::PdfDocument | |
| virtual | ~PdfDocument () |
| virtual PdfVersion | GetPdfVersion () const =0 |
| virtual bool | IsLinearized () const =0 |
| PdfOutlines & | GetOrCreateOutlines () |
| PdfNameTree & | GetOrCreateNameTree () |
| PdfAcroForm & | GetOrCreateAcroForm (PdfAcroFormDefaulAppearance eDefaultAppearance=PdfAcroFormDefaulAppearance::BlackText12pt) |
| void | EmbedSubsetFonts () |
| const PdfDocument & | Append (const PdfDocument &doc, bool appendAll=true) |
| const PdfDocument & | InsertExistingPageAt (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) |
| PdfFileSpec * | GetAttachment (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 |
| PdfObject & | GetCatalog () |
| const PdfObject & | GetCatalog () const |
| PdfPageTree & | GetPageTree () |
| const PdfPageTree & | GetPageTree () const |
| PdfObject & | GetTrailer () |
| const PdfObject & | GetTrailer () const |
| PdfInfo & | GetInfo () |
| const PdfInfo & | GetInfo () const |
| PdfIndirectObjectList & | GetObjects () |
| const PdfIndirectObjectList & | GetObjects () const |
| PdfObject * | GetStructTreeRoot () |
| PdfObject * | GetMetadata () |
| PdfObject * | GetMarkInfo () |
| PdfObject * | GetLanguage () |
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 () |
| PdfObject * | getCatalog () |
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 | ( | bool | empty = false | ) |
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. |
|
inline |
| 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 |
|
inlineoverridevirtual |
Get the PDF version of the document
Implements mm::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 |
| const PdfMemDocument & PdfMemDocument::InsertPages | ( | const PdfMemDocument & | doc, |
| unsigned | atIndex, | ||
| unsigned | pageCount | ||
| ) |
Copies one or more pages from another PdfMemDocument to this document
| doc | the document to append |
| atIndex | the first page number to copy (0-based) |
| pageCount | the number of pages to copy |
|
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!
Implements mm::PdfDocument.
|
overridevirtual |
Checks if text and graphics extraction is allowed. Every PDF-consuming application has to adhere to this value!
Implements mm::PdfDocument.
|
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!
Implements mm::PdfDocument.
|
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!
Implements mm::PdfDocument.
|
overridevirtual |
Checks if it is allowed to add or modify annotations or form fields. Every PDF-consuming application has to adhere to this value!
Implements mm::PdfDocument.
|
inline |
|
overridevirtual |
Checks if it is allowed to fill in existing form or signature fields. Every PDF-consuming application has to adhere to this value!
Implements mm::PdfDocument.
|
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!
Implements mm::PdfDocument.
|
inlineoverridevirtual |
Returns whether this PDF document is linearized, aka web-optimized
Implements mm::PdfDocument.
|
overridevirtual |
Checks if printing this document is allowed. Every PDF-consuming application has to adhere to this value!
Implements mm::PdfDocument.
| 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 std::string_view & | 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< PdfInputDevice > & | 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 PdfMemDocument::SetEncrypted | ( | const 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 & | userPassword, |
| const std::string & | 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) |
|
inline |
Set the PDF Version of the document. Has to be called before Write() to have an effect.
| version | version of the pdf document |
| void mm::PdfMemDocument::Write | ( | const std::string_view & | filename, |
| PdfSaveOptions | opts = PdfSaveOptions::None |
||
| ) |
Writes the complete document to a file
| filename | filename of the document |
This is an overloaded member function for your convenience.
| void PdfMemDocument::Write | ( | PdfOutputDevice & | device, |
| PdfSaveOptions | opts = PdfSaveOptions::None |
||
| ) |
Writes the complete document to an output device
| device | write to this output device |
| void mm::PdfMemDocument::WriteUpdate | ( | const std::string_view & | filename, |
| PdfSaveOptions | opts = PdfSaveOptions::None |
||
| ) |
Writes 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::WriteUpdate | ( | PdfOutputDevice & | device, |
| PdfSaveOptions | opts = PdfSaveOptions::None |
||
| ) |
Writes the document changes to an output device
| device | write to this output device |
| bTruncate | whether to truncate the device first and fill it with the content of the source document; the default is true. |
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.
The bTruncate is used to determine whether saving to the same file or not. In case the bTruncate is true, a new source stream is opened and its whole content is copied to the device first. Otherwise the device is the same file which had been loaded and the caller is responsible to position the device at the place, where the update should be written (basically at the end of the stream).