Comprehensive Guide for Developers: Features, Integration, and API Reference
Represents a PDF document. More...
#include <pdfsdk/cxx/document.h>
Public Member Functions | |
bool | IsCompressed () const |
Checks if the document is compressed. | |
bool | IsModified () const |
Checks if the document has been modified. | |
void | SetModified (bool modified) |
Sets the state of the document to modified. | |
std::filesystem::path | GetFilePath () const |
Gets the file path of the document. | |
void | Save (const std::filesystem::path &path, PDDocSaveFlags flags=kPDDocSaveFull|kPDDocSaveCompressed, ProgressMonitor *progmon=nullptr, const PDOptSaveSettings *optSettings=nullptr, const PDVersion *version=nullptr) |
A function to save a PDF file. | |
size_t | GetNumPages () const |
Gets the number of pages in the document. | |
Page | GetPage (size_t index) const |
Gets the page at the specified index. | |
Page | CreatePage (size_t insertAt, const RectF &mediaBox) |
Creates a new page at the specified index with the given media box. | |
void | CreatePages (size_t insertAt, size_t count, const RectF &mediaBox) |
Creates multiple pages starting at the specified index with the given media box. | |
void | DeletePages (const PDPageRange &range, ProgressMonitor *mon=nullptr) |
Deletes the pages within the specified range. | |
void | DeletePage (size_t index) |
Deletes the page at the specified index. | |
void | InsertPages (size_t insertAt, const Document &sourceDoc, const PDPageRange &sourceRange, ProgressMonitor *mon=nullptr) |
Inserts pages from another document into the current document. | |
void | InsertPage (const Page &page, size_t insertAt) |
Inserts a page at the specified index. | |
void | MovePages (size_t insertAt, const PDPageRange &range, ProgressMonitor *mon=nullptr) |
Moves pages within the document to a new position. | |
std::wstring | GetInfoString (PDAtom infoStringAtom) const |
Gets the information string associated with the specified info string atom. | |
void | SetInfoString (PDAtom infoStringAtom, const std::wstring &string) |
Sets the information string associated with the specified info string atom. | |
PDDateTime | GetCreationDate () const |
Gets the creation date of the document. | |
void | SetCreationDate (const PDDateTime &date) |
Sets the creation date of the document. | |
PDDateTime | GetModDate () const |
Gets the modification date of the document. | |
void | SetModDate (const PDDateTime &date) |
Sets the modification date of the document. | |
void | SetPageLayout (PDAtom layout) |
Sets the page layout of the document. | |
PDAtom | GetPageLayout () const |
Gets the page layout of the document. | |
void | SetPageMode (PDAtom mode) |
Sets the page mode of the document. | |
PDAtom | GetPageMode () const |
Gets the page mode of the document. | |
void | SetPageDirection (PDPageDirection direction) |
Sets the page direction of the document. | |
PDPageDirection | GetPageDirection () const |
Gets the page direction of the document. | |
XObject | CreateFormXObject (const Content &content) |
Creates a form XObject from the specified content stream. | |
Pattern | CreatePatternTiling (PDETilingPatternPaintType paintType, PDETilingPatternTilingType tilingType, const RectF &bbox, float xStep, float yStep, const Content &content) |
Creates a pattern object in the document using the specified pattern paint type. | |
Pattern | CreatePatternShading (const Shading &shading) |
Creates a pattern object in the document using the specified pattern shading. A shading pattern object is a PDF object that defines a smooth transition between colors. | |
Font | CreateFontInDoc (const PDFontInfo &fontInfo, bool needSubset=true, bool forceSysFont=true) |
Creates a font in the document using the specified font information. | |
size_t | GetNumFormFields () const |
Gets the number of form fields in the document. | |
FormField | GetField (size_t index) const |
Gets the form field at the specified index. | |
void | AppendField (FormField field) |
Appends a form field to the document. | |
void | RemoveField (FormField field) |
Removes the specified form field from the document. | |
FormField | CreateField (const std::wstring &fullname, PDAtom type, PDFieldFlags flags) |
Creates a new form field with the specified name, type, and flags. | |
FormField | FindField (const std::wstring &fullname) const |
Finds a form field with the specified full name. | |
void | RenameField (FormField field, const std::wstring &fullname) |
Renames a specified form field. | |
bool | IsSigned () const |
Checks if the document is signed. | |
void | SaveSignedVersion (FormField sigField, const std::filesystem::path &path) const |
Writes to a file the version of the document as it was at the time of signing. | |
Action | CreateActionURI (const std::string &uri) |
Creates a URI action with the specified URI. | |
Action | CreateActionGoTo (Dest dest) |
Creates a GoTo action with the specified destination. | |
Action | CreateActionJavaScript (const std::wstring &jscode) |
Creates a JavaScript action with the specified JavaScript code. | |
Action | CreateActionSubmitForm (const std::string &serverUri) |
Creates a SubmitForm action with the specified server URI. | |
Action | CreateActionResetForm () |
Creates a ResetForm action. | |
Action | CreateActionHide () |
Creates a Hide action. | |
Action | CreateActionNamed (PDAtom name) |
Creates a Named action with the specified name. | |
void | SetOpenAction (Action action) |
Sets the open action for the document. | |
Action | GetOpenAction () const |
Gets the open action of the document. | |
Dest | CreateDestXYZ (size_t pageIndex, const PointF &xy, float zoom, bool isRemote=false) |
Creates a destination with XYZ coordinates and zoom level. | |
Dest | CreateDestFit (size_t pageIndex, bool isRemote=false) |
Creates a destination that fits the entire page. | |
Dest | CreateDestFitH (size_t pageIndex, float top, bool isRemote=false) |
Creates a destination that fits the width of the page. | |
Dest | CreateDestFitV (size_t pageIndex, float left, bool isRemote=false) |
Creates a destination that fits the height of the page. | |
Dest | CreateDestFitR (size_t pageIndex, const RectF &rect, bool isRemote=false) |
Creates a destination that fits the specified rectangle on the page. | |
Dest | CreateDestFitB (size_t pageIndex, bool isRemote=false) |
Creates a destination that fits the bounding box of the page. | |
Dest | CreateDestFitBH (size_t pageIndex, float top, bool isRemote=false) |
Creates a destination that fits the width of the bounding box of the page. | |
Dest | CreateDestFitBV (size_t pageIndex, float left, bool isRemote=false) |
Creates a destination that fits the height of the bounding box of the page. | |
void | SetOpenDestination (Dest dest) |
Sets the open destination for the document. | |
Dest | GetOpenDestination () const |
Gets the open destination of the document. | |
template<class EnumProc > | |
void | EnumDocLevelJSActions (EnumProc enumProc) const |
Enumerates the document-level JavaScript actions. | |
Action | GetDocLevelJSAction (const std::wstring &name) const |
Gets the document-level JavaScript action with the specified name. | |
void | RemoveDocLevelJS () |
Removes the document-level JavaScript actions. | |
FileSpec | GetAttachment (const std::wstring &name) const |
Gets the attachment with the specified name. | |
template<class EnumProc > | |
void | EnumAttachments (EnumProc enumProc) const |
Enumerates the attachments in the document. | |
void | AddAttachment (const std::wstring &name, FileSpec filespec) |
Adds an attachment to the document. | |
void | RemoveAttachment (const std::wstring &name) |
Removes the attachment with the specified name. | |
size_t | GetNumAttachments () const |
Gets the number of attachments in the document. | |
std::wstring | GetAttachmentNameByIndex (size_t index) const |
Gets the name of the attachment at the specified index. | |
FileSpec | CreateFileSpec (PDAtom fileSys, const std::wstring &path) |
Creates a FileSpec with the specified file system and path. | |
FileSpec | CreateEmbeddedFile (const std::wstring &path) |
Creates an embedded file with the specified path. | |
Bookmark | GetRootBookmark () const |
Gets the root bookmark of the document. | |
Bookmark | CreateRootBookmark () |
Creates a root bookmark for the document. | |
OCConfig | GetOCConfig () const |
Gets the optional content (OC) configuration of the document. | |
OCGroup | CreateOCGroup (const std::wstring &name) |
Creates an optional content (OC) group with the specified name. | |
size_t | GetNumOCGroups () const |
Gets the number of optional content (OC) groups in the document. | |
OCGroup | GetOCGroup (size_t index) const |
Gets the optional content (OC) group at the specified index. | |
Annot | CreateTextAnnot (const RectF &rect) |
Creates a text annotation with the specified dimensions. | |
Annot | CreateTextMarkupAnnot (PDAtom type, PDColorValue color, const QuadPoints &quads) |
Creates a text markup annotation with the specified type, color, and quad points. | |
Annot | CreateInkAnnot (PDColorValue color, float lineWidth, const std::vector< std::vector< PointF > > &points) |
Creates an ink annotation with the specified color, line width, and points. | |
Annot | CreateFreeTextAnnot (const RectF &rect) |
Creates a free text annotation with the specified rectangle. | |
Annot | CreateStampAnnot (const RectF &rect, const XObject &appearance) |
Creates a (rubber) stamp annotation with the specified rectangle and appearance. | |
Annot | CreateButtonWidget (const FormField &field, const RectF &rect) |
Annot | CreateTextWidget (const FormField &field, const RectF &rect) |
Annot | CreateChoiceWidget (const FormField &field, const RectF &rect) |
Annot | CreateSignWidget (const FormField &field, const RectF &rect) |
Object | GetObjectByID (uint32_t id) const |
Gets the indirect object with the specified ID. | |
Object | GetRootObject () const |
Gets the root object of the document. | |
Object | GetInfoObject () const |
Gets the info object of the document. | |
Object | CreateBoolObject (bool value, bool indirect=false) |
Creates a boolean value object. | |
Object | CreateIntObject (int64_t value, bool indirect=false) |
Creates an integer value object. | |
Object | CreateRealObject (float value, bool indirect=false) |
Creates a real number object. | |
Object | CreateStringObjectUnicode (const std::wstring &unicode, bool indirect=false) |
Creates a literal string object from a Unicode string. | |
Object | CreateStringObject (const std::string &bytes, bool hex=false, bool indirect=false) |
Creates a string object from a byte string. | |
Object | CreateNameObject (PDAtom value, bool indirect=false) |
Creates a name object. | |
Object | CreateArrayObject (bool indirect) |
Creates an array object. | |
Object | CreateDictObject (bool indirect) |
Creates a dictionary object. | |
Object | CreateStreamObject (const void *buffer, size_t bufSize, const Object &attributesDict, const Object &encodeParms, bool encodeSource) |
Creates a stream object. | |
Object | CopyObject (const Object &source) |
Copies an object. | |
ReadStream | OpenXfaStream () const |
Opens an XFA (XML Forms Architecture) stream. | |
StdSecurityParams | GetStandardSecurityParams () const |
Gets the standard security parameters of the document. | |
void | SetStandardSecurityParams (const StdSecurityParams &requestedParams) |
Sets the standard security parameters of the document. | |
bool | RequestPermission (PDPermReqObj object, PDPermReqOp operation, const std::wstring &password=std::wstring()) const |
Requests permission to perform an operation on the document. Permissions can be set either by the document's security handler or by the DocMDP. | |
XObject | ImportIcon (const Document &source, size_t pageIndex=0) |
Imports an icon from another document. | |
void | CreatePageFromIcon (size_t insertAt, const Document &iconDoc, const XObject &icon) |
Creates a page from an icon. | |
Document (PDDoc handle, bool adopt=false) noexcept | |
Document (const Document &rhs) noexcept | |
Document & | operator= (const Document &rhs) noexcept |
Document (Document &&rhs) noexcept | |
Document & | operator= (Document &&rhs) noexcept |
Static Public Member Functions | |
static Document | NewDocument () |
A function to create an empty PDF file. | |
static Document | OpenDocument (const std::filesystem::path &path, const std::wstring &password=std::wstring()) |
A function to open a PDF file. | |
static Document | OpenDocument (const void *data, size_t size, bool copy=false, const std::wstring &password=std::wstring()) |
A function to open a PDF file from a memory buffer. | |
Represents a PDF document.
void PDF::Document::AddAttachment | ( | const std::wstring & | name, |
FileSpec | filespec ) |
Adds an attachment to the document.
[in] | name | A reference to the name of the attachment in wide character string format (i.e. L"FileAttachmentName"). |
[in] | filespec | The FileSpec of the attachment. |
void PDF::Document::AppendField | ( | FormField | field | ) |
Appends a form field to the document.
For more information refer to section 12.7 Forms from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | field | The form field to append. |
Copies an object.
[in] | source | A reference to the source object to copy. |
Creates a GoTo action with the specified destination.
A go-to action changes the view to a specified destination (page, location, and magnification factor). For more information refer to section 12.6.4.2 Go-To actions from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | dest | The destination for the action. The destination can be within the same document, another document or in an embedded file. |
Action PDF::Document::CreateActionHide | ( | ) |
Creates a Hide action.
This action hides or shows one or more annotations on the screen by setting or clearing their hidden flags. For more information refer to section 12.6.4.11 Hide actions from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Action PDF::Document::CreateActionJavaScript | ( | const std::wstring & | jscode | ) |
Creates a JavaScript action with the specified JavaScript code.
For more information refer to section 2.6.4.17 ECMAScript actions from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | jscode | A reference to the JavaScript code for the action in wide character string format (i.e. L"some javascript code to execute"). |
Action PDF::Document::CreateActionNamed | ( | PDAtom | name | ) |
Creates a Named action with the specified name.
Some common named actions are NextPage, PrevPage, FirstPage, LastPage, which do what their names suggest. For more information refer to section 12.6.4.12 Named actions from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | name | The name of the action. |
Action PDF::Document::CreateActionResetForm | ( | ) |
Creates a ResetForm action.
This action resets selected interactive form fields to their default values. For more information refer to section 12.7.6.3 Reset-form action from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Action PDF::Document::CreateActionSubmitForm | ( | const std::string & | serverUri | ) |
Creates a SubmitForm action with the specified server URI.
This action can be to transmit the names and values of selected interactive form fields to a specified uniform resource locator. For more information refer to section 12.7.6.2 Submit-form action from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | serverUri | A reference to the server URI for the action in wide character string format. |
Action PDF::Document::CreateActionURI | ( | const std::string & | uri | ) |
Creates a URI action with the specified URI.
This action causes the URI to be resolved. For more information refer to section 12.6.4.8 URI actions from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | uri | A reference to the URI for the action in wide character string format. (i.e. L"https://example.com") |
Object PDF::Document::CreateArrayObject | ( | bool | indirect | ) |
Creates an array object.
An array object is a one-dimensional collection of objects arranged sequentially. The array elements may be any combination of numbers, strings, dictionaries, or any other objects, including other arrays. For more information refer to section 7.3.6 Array objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | indirect | Indicates whether the object is indirect. |
Object PDF::Document::CreateBoolObject | ( | bool | value, |
bool | indirect = false ) |
Creates a boolean value object.
For more information refer to section 7.3.2 Boolean objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | value | The value of the boolean object. |
[in] | indirect | Indicates whether the object is indirect. |
Dest PDF::Document::CreateDestFit | ( | size_t | pageIndex, |
bool | isRemote = false ) |
Creates a destination that fits the entire page.
Fits the entire page within the window both horizontally and vertically. For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /Fit
[in] | pageIndex | The specific page to be displayed. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Dest PDF::Document::CreateDestFitB | ( | size_t | pageIndex, |
bool | isRemote = false ) |
Creates a destination that fits the bounding box of the page.
For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /FitB
[in] | pageIndex | The specific page to be displayed. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Dest PDF::Document::CreateDestFitBH | ( | size_t | pageIndex, |
float | top, | ||
bool | isRemote = false ) |
Creates a destination that fits the width of the bounding box of the page.
For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /FitBH
[in] | pageIndex | The specific page to be displayed. |
[in] | top | The vertical coordinate positioned at the top edge of the window. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Dest PDF::Document::CreateDestFitBV | ( | size_t | pageIndex, |
float | left, | ||
bool | isRemote = false ) |
Creates a destination that fits the height of the bounding box of the page.
For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /FitBV
[in] | pageIndex | The specific page to be displayed. |
[in] | left | The horizontal coordinate positioned at the left edge of the window. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Dest PDF::Document::CreateDestFitH | ( | size_t | pageIndex, |
float | top, | ||
bool | isRemote = false ) |
Creates a destination that fits the width of the page.
For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /FitH
[in] | pageIndex | The specific page to be displayed. |
[in] | top | The vertical coordinate positioned at the top edge of the window. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Creates a destination that fits the specified rectangle on the page.
For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /FitR
[in] | pageIndex | The specific page to be displayed. |
[in] | rect | A reference to the rectangle to fit inside of. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Dest PDF::Document::CreateDestFitV | ( | size_t | pageIndex, |
float | left, | ||
bool | isRemote = false ) |
Creates a destination that fits the height of the page.
For more information refer to section 12.3.2.2 Explicit destinations, Table 149 — Destination syntax, /FitV
[in] | pageIndex | The specific page to be displayed. |
[in] | left | The horizontal coordinate positioned at the left edge of the window. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Dest PDF::Document::CreateDestXYZ | ( | size_t | pageIndex, |
const PointF & | xy, | ||
float | zoom, | ||
bool | isRemote = false ) |
Creates a destination with XYZ coordinates and zoom level.
A destination defines a particular view of a document. For more information refer to section 12.3.2 Destinations and Table 149 — Destination syntax, /XYZ from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | pageIndex | The specific page to be displayed. |
[in] | xy | A reference to the location of the document window. |
[in] | zoom | The magnification factor. |
[in] | isRemote | [Optional] Indicates whether the destination is at the current document. |
Object PDF::Document::CreateDictObject | ( | bool | indirect | ) |
Creates a dictionary object.
The keys shall be direct objects, the values may be any kind of object, including another dictionary. A dictionary entry whose value is null shall be treated the same as if the entry does not exist. For more information refer to section 7.3.7 Dictionary objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | indirect | Indicates whether the object is indirect. |
FileSpec PDF::Document::CreateEmbeddedFile | ( | const std::wstring & | path | ) |
Creates an embedded file with the specified path.
[in] | path | A reference to the path of the embedded file in wide character string format (i.e. L"path/to/embedded/file") |
FormField PDF::Document::CreateField | ( | const std::wstring & | fullname, |
PDAtom | type, | ||
PDFieldFlags | flags ) |
Creates a new form field with the specified name, type, and flags.
[in] | fullname | A reference to the name of the form field in wide character string format. (i.e. L"email address") |
[in] | type | The type of the form field. This can be a Button, Text, Choice or Signature. For more information refer to section 12.7.4 Field dictionaries, Table 226 — Entries common to all field dictionaries, key FT (Field Type). |
[in] | flags | The flags defining the form field. Specifies the control, behavior and appearance of th form field. |
FileSpec PDF::Document::CreateFileSpec | ( | PDAtom | fileSys, |
const std::wstring & | path ) |
Creates a FileSpec with the specified file system and path.
[in] | fileSys | The file system of the FileSpec. |
[in] | path | A reference to the path of the FileSpec in wide character string format. |
Font PDF::Document::CreateFontInDoc | ( | const PDFontInfo & | fontInfo, |
bool | needSubset = true, | ||
bool | forceSysFont = true ) |
Creates a font in the document using the specified font information.
[in] | fontInfo | A reference to the font information. This includes the font family (Times New Roman, Arial etc.), format (i.e. TrueType TTF) and style (regular, bold, italic) For information on font formats refer to section 9.5 Introduction to font data structures and Table 108 — Font types from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
[in] | needSubset | [Optional] Indicates whether the font needs to be subsetted (default: true). Subsetting includes only the glyphs (characters) that are actually used in the document, rather than embedding the entire font. This can significantly reduce the file size of the PDF. For more information refer to section 9.9.2 Font subsets from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
[in] | forceSysFont | [Optional] Indicates whether to force using system fonts (default: true). A flag used to determine whether to use a font that is installed on the system processing the PDF document. This maintains a uniform appearance across different documents and applications on the same system. |
Creates a form XObject from the specified content stream.
A form XObject is a PDF content stream that is a self-contained description of any sequence of graphics objects (including path objects, text objects, and sampled images). For more information refer to sections 8.8 External objects and 8.10 Form XObjects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | content | The content stream used to create the form XObject. It is a sequence of instructions describing the graphical elements to be painted on a page. For more information refer to section 7.8.2 Content streams from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
Creates a free text annotation with the specified rectangle.
A free text annotation is always visible, because it has no open or closed state. It is not displayed in a popup window like an ordinary text annotation. For more information refer to section 12.5.6.6 Free text annotations from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | rect | A reference to the inner rectangle where the annotation’s text will be displayed. |
Annot PDF::Document::CreateInkAnnot | ( | PDColorValue | color, |
float | lineWidth, | ||
const std::vector< std::vector< PointF > > & | points ) |
Creates an ink annotation with the specified color, line width, and points.
For more information refer to section 12.5.6.13 Ink annotations ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | color | The color of the ink annotation. |
[in] | lineWidth | The line width of the ink annotation. |
[in] | points | A reference to the coordinates that define the path of the ink annotation on the page. |
Object PDF::Document::CreateIntObject | ( | int64_t | value, |
bool | indirect = false ) |
Creates an integer value object.
For more information refer to section 7.3.3 Numeric objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | value | The value of the integer object. |
[in] | indirect | Indicates whether the object is indirect. |
Object PDF::Document::CreateNameObject | ( | PDAtom | value, |
bool | indirect = false ) |
Creates a name object.
A name object is an atomic symbol uniquely defined by a sequence of any characters (8-bit values) except null (character code 0). For more information refer to section 7.3.5 Name objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | value | The value of the name object. |
[in] | indirect | Indicates whether the object is indirect. |
OCGroup PDF::Document::CreateOCGroup | ( | const std::wstring & | name | ) |
Creates an optional content (OC) group with the specified name.
An OC group is a dictionary representing a collection of graphics that can be made visible or invisible dynamically. For more information refer to section 8.11.2 Optional content groups and 8.11.4 Configuring optional content from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | name | A reference to the name of the optional content group in wide character string format (i.e. L"OCGroupName") |
Creates a new page at the specified index with the given media box.
[in] | insertAt | The index at which to insert the new page. |
[in] | mediaBox | The media box of the new page. For more information refer to section 14.11.2 Page boundaries from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
void PDF::Document::CreatePageFromIcon | ( | size_t | insertAt, |
const Document & | iconDoc, | ||
const XObject & | icon ) |
Creates a page from an icon.
[in] | insertAt | The location at which to insert the page at. |
[in] | iconDoc | A reference to the document containing the icon. |
[in] | icon | A reference to the icon to create the page from. A form XObject is a PDF content stream that is a self-contained description of any sequence of graphics objects (including path objects, text objects, and sampled images). For more information refer to sections 8.8 External objects and 8.10 Form XObjects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
void PDF::Document::CreatePages | ( | size_t | insertAt, |
size_t | count, | ||
const RectF & | mediaBox ) |
Creates multiple pages starting at the specified index with the given media box.
[in] | insertAt | The index at which to insert the new pages. |
[in] | count | The number of pages to create. |
[in] | mediaBox | The media box of the new pages. For more information refer to section 14.11.2 Page boundaries from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
Creates a pattern object in the document using the specified pattern shading. A shading pattern object is a PDF object that defines a smooth transition between colors.
[in] | shading | The shading object used to create the pattern. |
Pattern PDF::Document::CreatePatternTiling | ( | PDETilingPatternPaintType | paintType, |
PDETilingPatternTilingType | tilingType, | ||
const RectF & | bbox, | ||
float | xStep, | ||
float | yStep, | ||
const Content & | content ) |
Creates a pattern object in the document using the specified pattern paint type.
A tiling pattern object is a PDF object that defines a repeating graphical element.
[in] | paintType | The type of pattern paint to create. |
[in] | tilingType | The type of tiling pattern to create. |
[in] | bbox | The bounding box of the pattern. |
[in] | xStep | The horizontal spacing between pattern cells. Shall not be zero. |
[in] | yStep | The vertical spacing between pattern cells. Shall not be zero. |
[in] | content | The content stream used to create the pattern. |
Object PDF::Document::CreateRealObject | ( | float | value, |
bool | indirect = false ) |
Creates a real number object.
For more information refer to section 7.3.3 Numeric objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | value | The value of the real object. |
[in] | indirect | Indicates whether the object is indirect. |
Bookmark PDF::Document::CreateRootBookmark | ( | ) |
Creates a root bookmark for the document.
For more information see section 12.3.3 Document outline from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Creates a (rubber) stamp annotation with the specified rectangle and appearance.
For more information refer to section 12.5.6.12 Rubber stamp annotations from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | rect | A reference to the inner rectangle where the annotation’s text will be displayed. |
[in] | appearance | A reference to the external graphics object specifying the visual representation of the stamp annotation. |
Object PDF::Document::CreateStreamObject | ( | const void * | buffer, |
size_t | bufSize, | ||
const Object & | attributesDict, | ||
const Object & | encodeParms, | ||
bool | encodeSource ) |
Creates a stream object.
For more information refer to section 7.3.8 Stream objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | buffer | A pointer to the buffer that contains the stream data. |
[in] | bufSize | The size of the buffer. This is the Length key inside the stream dictionary, For more information refer to Table 5 — Entries common to all stream dictionaries. |
[in] | attributesDict | A reference to the dictionary object containing the stream attributes. |
[in] | encodeParms | A reference to the dictionary object containing the encoding parameters. |
[in] | encodeSource | Indicates whether to encode the source data. |
Object PDF::Document::CreateStringObject | ( | const std::string & | bytes, |
bool | hex = false, | ||
bool | indirect = false ) |
Creates a string object from a byte string.
For more information refer to section 7.3.4 String objects and section 7.3.4.3 Hexadecimal strings from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | bytes | A reference to the byte string. |
[in] | hex | [Optional] Indicates whether the byte string is in hexadecimal format |
[in] | indirect | Indicates whether the object is indirect. |
Object PDF::Document::CreateStringObjectUnicode | ( | const std::wstring & | unicode, |
bool | indirect = false ) |
Creates a literal string object from a Unicode string.
For more information refer to section 7.3.4 String objects and section 7.3.4.2 Literal strings from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | unicode | A reference to the Unicode string in wide character string format. |
[in] | indirect | Indicates whether the object is indirect. |
Creates a text annotation with the specified dimensions.
For more information refer to section 12.5 Annotations from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | rect | A reference to the rectangle surrounding the text annotation. |
Annot PDF::Document::CreateTextMarkupAnnot | ( | PDAtom | type, |
PDColorValue | color, | ||
const QuadPoints & | quads ) |
Creates a text markup annotation with the specified type, color, and quad points.
For more information refer to section 12.5.6.2 Markup annotations ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | type | The type of the text markup annotation. |
[in] | color | The color of the text markup annotation. |
[in] | quads | A reference to the corners of the text markup annotation boundary. |
void PDF::Document::DeletePage | ( | size_t | index | ) |
Deletes the page at the specified index.
[in] | index | The index of the page to delete. |
void PDF::Document::DeletePages | ( | const PDPageRange & | range, |
ProgressMonitor * | mon = nullptr ) |
Deletes the pages within the specified range.
[in] | range | The range of pages to delete. |
[out] | mon | [Optional] A pointer to the progress monitor handle that displays the progress/state of the operation. If not provided, defaults to a null pointer. ProgressMonitor |
void PDF::Document::EnumAttachments | ( | EnumProc | enumProc | ) | const |
Enumerates the attachments in the document.
EnumProc | The type of the enumeration procedure. |
[in] | enumProc | The enumeration procedure to be called for each attachment. |
void PDF::Document::EnumDocLevelJSActions | ( | EnumProc | enumProc | ) | const |
Enumerates the document-level JavaScript actions.
EnumProc | The type of the enumeration procedure. |
[in] | enumProc | The enumeration procedure to be called for each JavaScript action. |
FormField PDF::Document::FindField | ( | const std::wstring & | fullname | ) | const |
Finds a form field with the specified full name.
[in] | fullname | A reference to the name of the form field to retrieve, in wide character string format (i.e. L"email address"). |
FileSpec PDF::Document::GetAttachment | ( | const std::wstring & | name | ) | const |
Gets the attachment with the specified name.
[in] | name | A reference to the name of the attachment in wide character string format (i.e. L"FileAttachmentName") |
std::wstring PDF::Document::GetAttachmentNameByIndex | ( | size_t | index | ) | const |
Gets the name of the attachment at the specified index.
[in] | index | The index of the attachment. |
PDDateTime PDF::Document::GetCreationDate | ( | ) | const |
Gets the creation date of the document.
Retrieved from the document's information dictionary CreationDate entry. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Action PDF::Document::GetDocLevelJSAction | ( | const std::wstring & | name | ) | const |
Gets the document-level JavaScript action with the specified name.
[in] | name | A reference to the name of the JavaScript action. |
FormField PDF::Document::GetField | ( | size_t | index | ) | const |
Gets the form field at the specified index.
For more information refer to section 12.7 Forms from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | index | The index of the form field. |
std::filesystem::path PDF::Document::GetFilePath | ( | ) | const |
Gets the file path of the document.
Object PDF::Document::GetInfoObject | ( | ) | const |
Gets the info object of the document.
This is the document information dictionary, which is used to represent document level metadata. It is located in the Info entry of the file trailer. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
std::wstring PDF::Document::GetInfoString | ( | PDAtom | infoStringAtom | ) | const |
Gets the information string associated with the specified info string atom.
[in] | infoStringAtom | The Atom specifies what information string to retrieve from the document's information dictionary. The supported atoms: Author, Title, Subject, Keywords, Creator, Producer. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
PDDateTime PDF::Document::GetModDate | ( | ) | const |
Gets the modification date of the document.
Retrieved from the document's information dictionary ModDate entry. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
size_t PDF::Document::GetNumAttachments | ( | ) | const |
Gets the number of attachments in the document.
size_t PDF::Document::GetNumFormFields | ( | ) | const |
Gets the number of form fields in the document.
For more information refer to section 12.7 Forms from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
size_t PDF::Document::GetNumOCGroups | ( | ) | const |
Gets the number of optional content (OC) groups in the document.
An OC group is a dictionary representing a collection of graphics that can be made visible or invisible dynamically. For more information refer to section 8.11.2 Optional content groups from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
size_t PDF::Document::GetNumPages | ( | ) | const |
Gets the number of pages in the document.
Object PDF::Document::GetObjectByID | ( | uint32_t | id | ) | const |
Gets the indirect object with the specified ID.
For more information refer to section 7.3 Objects from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | id | The ID of the object. |
OCConfig PDF::Document::GetOCConfig | ( | ) | const |
Gets the optional content (OC) configuration of the document.
Optional content refers to sections of content in a PDF document that can be selectively viewed or hidden by document authors or consumers. For more information refer to section 8.11 Optional content from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
OCGroup PDF::Document::GetOCGroup | ( | size_t | index | ) | const |
Gets the optional content (OC) group at the specified index.
An OC group is a dictionary representing a collection of graphics that can be made visible or invisible dynamically. For more information refer to section 8.11.2 Optional content groups from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | index | The index of the optional content group. |
Action PDF::Document::GetOpenAction | ( | ) | const |
Gets the open action of the document.
Dest PDF::Document::GetOpenDestination | ( | ) | const |
Gets the open destination of the document.
Page PDF::Document::GetPage | ( | size_t | index | ) | const |
Gets the page at the specified index.
[in] | index | The index of the page. |
PDPageDirection PDF::Document::GetPageDirection | ( | ) | const |
Gets the page direction of the document.
Retrieves the reading and writing order of text on a page. It can be either left to right (i.e. for English) or right to left (i.e. for Arabic). For more information refer to section 12.2 Viewer preferences Table 147 — Entries in a viewer preferences dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
PDAtom PDF::Document::GetPageLayout | ( | ) | const |
Gets the page layout of the document.
Retrieves the details about how a document's pages are displayed, when first opened. There are six possible layouts - one page at a time, pages in a column etc. For more information refer to section 7.7.2 Document catalog dictionary table Table 29 — Entries in the catalog dictionary, key PageLayout from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
PDAtom PDF::Document::GetPageMode | ( | ) | const |
Gets the page mode of the document.
This retrieves what a document's menu bar/sidebar is set to display, when a document is first opened. This could be the document's outline, thumbnails or attachments panel etc. For more information refer to section 7.7.2 Document catalog dictionary table Table 29 — Entries in the catalog dictionary, key PageMode from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Bookmark PDF::Document::GetRootBookmark | ( | ) | const |
Gets the root bookmark of the document.
This is the root of the tree-structured hierarchy of the document's outline items (bookmarks). For more information see section 12.3.3 Document outline from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Object PDF::Document::GetRootObject | ( | ) | const |
Gets the root object of the document.
This is the document catalogue dictionary, which is the root of a document's object heirarchy. It is located in the Root entry of the file trailer. For more information refer to section 7.7.2 Document catalog dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
StdSecurityParams PDF::Document::GetStandardSecurityParams | ( | ) | const |
Gets the standard security parameters of the document.
These include the editing, printing and data extraction permissions as well as owner and user password properties. For more information on Security Parameters refer to section 7.6.4 Standard security handler from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
Imports an icon from another document.
An icon is the visual representation of any of the annotation types when they are not interacted with. It represents the existence and location for an annotation and contains clues as to the type of annotation (i.e. a sound annotation will have a speaker displayed).
[in] | source | A reference to the source document. |
[in] | pageIndex | [Optional] The index of the page containing the icon (Default is 0). |
void PDF::Document::InsertPage | ( | const Page & | page, |
size_t | insertAt ) |
Inserts a page at the specified index.
[in] | page | A reference to the page to insert. |
[in] | insertAt | The index at which to insert the page. |
void PDF::Document::InsertPages | ( | size_t | insertAt, |
const Document & | sourceDoc, | ||
const PDPageRange & | sourceRange, | ||
ProgressMonitor * | mon = nullptr ) |
Inserts pages from another document into the current document.
[in] | insertAt | The index at which to insert the pages. |
[in] | sourceDoc | A reference to the source document from which to insert the pages. |
[in] | sourceRange | A reference to the range of pages to insert from the source document. |
[out] | mon | [Optional] A pointer to the progress monitor handle that displays the progress/state of the operation. If not provided, defaults to a null pointer. ProgressMonitor |
bool PDF::Document::IsCompressed | ( | ) | const |
Checks if the document is compressed.
bool PDF::Document::IsModified | ( | ) | const |
Checks if the document has been modified.
bool PDF::Document::IsSigned | ( | ) | const |
Checks if the document is signed.
For further information refer to section 12.7.5.5 Signature fields from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
void PDF::Document::MovePages | ( | size_t | insertAt, |
const PDPageRange & | range, | ||
ProgressMonitor * | mon = nullptr ) |
Moves pages within the document to a new position.
[in] | insertAt | The index at which to insert the moved pages. |
[in] | range | The range of pages to move. |
[out] | mon | [Optional] A pointer to the progress monitor handle that displays the progress/state of the operation. If not provided, defaults to a null pointer. ProgressMonitor |
|
static |
A function to create an empty PDF file.
|
static |
A function to open a PDF file.
[in] | path | The full or relative path to an existing PDF file, including the file extension. |
[in] | password | [Optional] Password for the PDF file to open. If the file is not password protected it defaults to an empty string. Supports Unicode. |
|
static |
A function to open a PDF file from a memory buffer.
[in] | data | The memory buffer containing the PDF file. |
[in] | size | The size of the memory buffer. |
[in] | copy | A flag to indicate if the data should be copied. If set to false, the buffer must remain valid until the document is closed. |
[in] | password | Password for the PDF file to open. If the file is not password protected it defaults to an empty string. Supports Unicode. |
ReadStream PDF::Document::OpenXfaStream | ( | ) | const |
Opens an XFA (XML Forms Architecture) stream.
An XFA stream is the object that contains the XML data describing an XFA form. For more information refer to Annex K (normative) XFA Forms from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
void PDF::Document::RemoveAttachment | ( | const std::wstring & | name | ) |
Removes the attachment with the specified name.
[in] | name | A reference to the name of the attachment to remove in wide character string format (i.e. L"FileAttachmentName"). |
void PDF::Document::RemoveField | ( | FormField | field | ) |
Removes the specified form field from the document.
For more information refer to section 12.7 Forms from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | field | The form field to remove. |
void PDF::Document::RenameField | ( | FormField | field, |
const std::wstring & | fullname ) |
Renames a specified form field.
[in] | field | The form field to retrieve and rename. |
[in] | fullname | A reference to the new name of the form field, in wide character string format. (i.e. L"email address") |
bool PDF::Document::RequestPermission | ( | PDPermReqObj | object, |
PDPermReqOp | operation, | ||
const std::wstring & | password = std::wstring() ) const |
Requests permission to perform an operation on the document. Permissions can be set either by the document's security handler or by the DocMDP.
[in] | object | The object to request permission for. |
[in] | operation | The operation to request permission for. |
[in] | password | The password to use for the authorization. |
void PDF::Document::Save | ( | const std::filesystem::path & | path, |
PDDocSaveFlags | flags = kPDDocSaveFull|kPDDocSaveCompressed, | ||
ProgressMonitor * | progmon = nullptr, | ||
const PDOptSaveSettings * | optSettings = nullptr, | ||
const PDVersion * | version = nullptr ) |
A function to save a PDF file.
[in] | path | The full or relative path to the location where you want the PDF file saved. |
[in] | flags | [Optional] An integer that specifies the type of save. For more information refer to the PDF Standard ISO 32000-2:2020 (PDF 2.0) sections: 12.8 - Digital Signatures p.575, Annex F - Linearized PDF and 7.5 File Structure respectively. PDDocSaveFlagsBits |
[out] | progmon | [Optional] A pointer to the progress monitor handle that displays the progress/state of the operation. If not provided, defaults to a null pointer. ProgressMonitor |
[in] | optSettings | [Optional] Options for level of PDF image quality and saving/removing of PDF structure internals. If not provided, defaults to a null pointer. PDOptSaveSettings |
[in] | version | [Optional] Major and Minor version of the PDF file type. The convention being Major.Minor i.e. PDF 2.0 For more information refer to the PDF Standard ISO 32000-2:2020 (PDF 2.0) Annex I - PDF versions and compatibility. If not provided, defaults to a null pointer. |
void PDF::Document::SaveSignedVersion | ( | FormField | sigField, |
const std::filesystem::path & | path ) const |
Writes to a file the version of the document as it was at the time of signing.
[in] | sigField | The signature field that was used to sign the document. |
[in] | path | The path to the location where you want the signed version of the document saved. |
void PDF::Document::SetCreationDate | ( | const PDDateTime & | date | ) |
Sets the creation date of the document.
Set into the document's information dictionary CreationDate entry. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | date | A reference to the creation date to set. For format details refer to section 7.9.4 Dates from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
void PDF::Document::SetInfoString | ( | PDAtom | infoStringAtom, |
const std::wstring & | string ) |
Sets the information string associated with the specified info string atom.
[in] | infoStringAtom | The Atom specifies what information string to set inside the document's information dictionary. The supported atoms: Author, Title, Subject, Keywords, Creator, Producer. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
[in] | string | A reference to the information string to set. (i.e. set infoStringAtom = Author to string = L"Author Name") |
void PDF::Document::SetModDate | ( | const PDDateTime & | date | ) |
Sets the modification date of the document.
Set into the document's information dictionary ModDate entry. For more information refer to section 14.3.3 Document information dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | date | The modification date to set. For format details refer to section 7.9.4 Dates from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. |
void PDF::Document::SetModified | ( | bool | modified | ) |
Sets the state of the document to modified.
[in] | modified | The modified flag to set the state. |
void PDF::Document::SetOpenAction | ( | Action | action | ) |
Sets the open action for the document.
This defines an action that should be executed automatically when the PDF document is opened
[in] | action | The action executed at document opening. |
void PDF::Document::SetOpenDestination | ( | Dest | dest | ) |
Sets the open destination for the document.
[in] | dest | The destination to set as the open destination. |
void PDF::Document::SetPageDirection | ( | PDPageDirection | direction | ) |
Sets the page direction of the document.
This specifies reading and writing order of text on a page. The two possible directions are left to right for English, Spanish, Chinese, and most Western languages and right to left for Arabic, Hebrew, Persian etc. For more information refer to section 12.2 Viewer preferences Table 147 — Entries in a viewer preferences dictionary from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | direction | The page direction to set. |
void PDF::Document::SetPageLayout | ( | PDAtom | layout | ) |
Sets the page layout of the document.
This defines how a document's pages are displayed, when first opened. There are six possible layouts - one page at a time, pages in a column etc. For more information refer to section 7.7.2 Document catalog dictionary table Table 29 — Entries in the catalog dictionary, key PageLayout from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | layout | The page layout to set. |
void PDF::Document::SetPageMode | ( | PDAtom | mode | ) |
Sets the page mode of the document.
This defines what a document's menu bar/sidebar displays, when a document is first opened. The document's outline, thumbnails or attachments panel can be made visible among others. For more information refer to section 7.7.2 Document catalog dictionary table Table 29 — Entries in the catalog dictionary, key PageMode from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | mode | The page mode to set. |
void PDF::Document::SetStandardSecurityParams | ( | const StdSecurityParams & | requestedParams | ) |
Sets the standard security parameters of the document.
These include the editing, printing and data extraction permissions as well as owner and user password properties. For more information on Security Parameters refer to section 7.6.4 Standard security handler from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.
[in] | requestedParams | A reference to the standard security parameters to set. |