PDFix SDK  5.0.27
PdfDoc Struct Referenceabstract

PdfDoc class. More...

Public Member Functions

virtual bool Save (const wchar_t *path, PdfSaveFlags flags)=0
 
virtual bool SaveToStream (PsStream *stream, PdfSaveFlags flags)=0
 
virtual bool Close ()=0
 Closes a document and releases its resources. Changes are not saved. More...
 
virtual bool AddWatermarkFromImage (PdfWatermarkParams *params, const wchar_t *path)=0
 Adds an image-based watermark to a page range in the given document. More...
 
virtual int GetNumPages ()=0
 Gets the number of pages in a document. More...
 
virtual PdfPageAcquirePage (int page_num)=0
 
virtual int GetNumDocumentJavaScripts ()=0
 Gets the number of document JavaScript name/action pairs in the document JavaScript name tree. More...
 
virtual int GetDocumentJavaScript (int index, _out_ wchar_t *buffer, int len)=0
 Gets the document JavaScript action by it's index in th documente JavaScript name tree. More...
 
virtual int GetDocumentJavaScriptName (int index, _out_ wchar_t *buffer, int len)=0
 Gets the document JavaScript action name by it's index in th documente JavaScript name tree. More...
 
virtual int GetNumCalculatedFormFields ()=0
 Gets the number of calculated form fields in AcroForm calculated order (CO) which is an array. More...
 
virtual PdfFormFieldGetCalculatedFormField (int index)=0
 Gets the calculated form field from AcroForm calculation order array (CO) by index. More...
 
virtual int GetNumFormFields ()=0
 Gets the total number of form fields in document's AcroForm Fields tree. More...
 
virtual PdfFormFieldGetFormField (int index)=0
 Gets the form field in document's AcroForm Fields tree by index. More...
 
virtual PdfFormFieldGetFormFieldByName (const wchar_t *buffer)=0
 Gets the form field in document's AcroForm Fields tree by name. More...
 
virtual int GetInfo (const wchar_t *key, _out_ wchar_t *buffer, int len)=0
 Gets the value of a key in a document's Info dictionary. More...
 
virtual bool SetInfo (const wchar_t *key, const wchar_t *info)=0
 Sets the value of a key in a document's Info dictionary. More...
 
virtual PdfBookmarkGetBookmarkRoot ()=0
 
virtual bool FlattenAnnots (PdfFlattenAnnotsParams *params)=0
 
virtual int GetNumAlternates ()=0
 Gets the number of PDF alternate in the document. More...
 
virtual PdfAlternateAcquireAlternate (int index)=0
 Gets the PDF alternate based on it's index. More...
 
virtual PdsObjectCreatePdsObject (PdfObjectType type, bool indirect)=0
 Creates a new PdsObject associated with the specified document. More...
 
virtual bool AddTags (_callback_ PdfCancelProc cancel_proc, void *cancel_data)=0
 Add tags into document. More...
 
virtual bool RemoveTags (_callback_ PdfCancelProc cancel_proc, void *cancel_data)=0
 
virtual PdfDocTemplateGetDocTemplate ()=0
 Accesses document template. More...
 
virtual PsMetadataGetMetadata ()=0
 Gets documnent metadata. More...
 
virtual int GetLang (_out_ wchar_t *buffer, int len)=0
 Gets documnent primary language. More...
 
virtual bool SetLang (const wchar_t *lang)=0
 Sets documnent primary language. More...
 
virtual bool EmbedFonts (bool subset, _callback_ PdfCancelProc cancel_proc, void *cancel_data)=0
 Embeds or subsets fonts used in the document. More...
 
virtual bool MakeAccessible (PdfAccessibleParams *params, _callback_ PdfCancelProc cancel_proc, void *cancel_data)=0
 Makes a PDF document accessible. More...
 
virtual PdsDictionaryGetRootObject ()=0
 Gets the document catalog dictionary which is a Root entry. More...
 
virtual PdsDictionaryGetInfoObject ()=0
 Gets the Info dictionary of the document. More...
 
virtual PdsDictionaryCreateDictObject (bool indirect)=0
 Create new PdsDictionary object. More...
 
virtual PdsArrayCreateArrayObject (bool indirect)=0
 Create new PdsArray object. More...
 
virtual PdsNameCreateNameObject (bool indirect, const wchar_t *value)=0
 Create new PdsName object. More...
 
virtual PdsStringCreateStringObject (bool indirect, const wchar_t *value, bool hex)=0
 Create new PdsString object. More...
 
virtual PdsNumberCreateIntObject (bool indirect, int value)=0
 Create new PdsNumber (integer) object. More...
 
virtual PdsNumberCreateNumberObject (bool indirect, double value)=0
 Create new PdsNumber (float) object. More...
 
virtual PdsStreamCreateStreamObject (bool indirect, PdsDictionary *dict, _in_ const uint8_t *buffer, int size)=0
 Create new PdsStream object. More...
 
virtual PdsObjectGetObjectById (int obj_id)=0
 Get the document object by number. More...
 
virtual PdsStructTreeCreateStructTree ()=0
 
virtual PdsStructTreeGetStructTree ()=0
 Gets the Struct Tree root object of the document. More...
 
virtual void RemoveStructTree ()=0
 
virtual void RemoveBookmarks ()=0
 Removes all bookmarks from the document. More...
 
virtual bool CreateBookmarks (_callback_ PdfCancelProc cancel_proc, void *cancel_data)=0
 Create bookmark tree from the document's structure tree headings. More...
 
virtual bool AddFontMissingUnicode (_callback_ PdfCancelProc cancel_proc, void *cancel_data)=0
 Search used font's characters and add appropriate unicode character if not present. More...
 

Detailed Description

PdfDoc class.

A PdfDoc object represents a PDF document.

Member Function Documentation

◆ AcquireAlternate()

virtual PdfAlternate* PdfDoc::AcquireAlternate ( int  index)
pure virtual

Gets the PDF alternate based on it's index.

Parameters
indexThe index of an alternate.

◆ AcquirePage()

virtual PdfPage* PdfDoc::AcquirePage ( int  page_num)
pure virtual

Gets a PdfPage from a document. The page is cached, so that subsequent calls on the same PDPage return The same PdfPage and increments the reference count. The page remains in the cache as long as document exists or PdfPage::Release was not called. AcquirePage increments a page’s reference count. The page will not be released until the reference count is zero, or the application terminates. NOTE: After you are done using the page, release it using PdfPage::Release to release resources.


Parameters
page_numThe page number of the page to get. The first page is 0.
Returns
The requested page.
See also
PdfPage::Release

◆ AddFontMissingUnicode()

virtual bool PdfDoc::AddFontMissingUnicode ( _callback_ PdfCancelProc  cancel_proc,
void *  cancel_data 
)
pure virtual

Search used font's characters and add appropriate unicode character if not present.

Parameters
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.
Returns
true if successfull. false othervise
See also
PdfDoc::EmbedFonts

◆ AddTags()

virtual bool PdfDoc::AddTags ( _callback_ PdfCancelProc  cancel_proc,
void *  cancel_data 
)
pure virtual

Add tags into document.

Parameters
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.
Returns
true if tags were added successfuly, false otherwise.

◆ AddWatermarkFromImage()

virtual bool PdfDoc::AddWatermarkFromImage ( PdfWatermarkParams params,
const wchar_t *  path 
)
pure virtual

Adds an image-based watermark to a page range in the given document.

Parameters
paramsStructure specifying how the watermark should be added to the document.
pathPath to the image file. Only JPEG format is supported for now.
Returns
true if the watermark was added succsessfully, false otherwise. Sample AddWatermark

◆ Close()

virtual bool PdfDoc::Close ( )
pure virtual

Closes a document and releases its resources. Changes are not saved.

Returns
true if document was closed succsessfully, false otherwise.
See also
PdfDoc::Save

◆ CreateArrayObject()

virtual PdsArray* PdfDoc::CreateArrayObject ( bool  indirect)
pure virtual

Create new PdsArray object.

Parameters
indirectif true the method creates indorect object othervise a direct object.
Returns
newly created PdsArray object.

◆ CreateBookmarks()

virtual bool PdfDoc::CreateBookmarks ( _callback_ PdfCancelProc  cancel_proc,
void *  cancel_data 
)
pure virtual

Create bookmark tree from the document's structure tree headings.

Parameters
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.
Returns
true if successfull. false othervise
See also
PdfDoc::RemoveBookmarks

◆ CreateDictObject()

virtual PdsDictionary* PdfDoc::CreateDictObject ( bool  indirect)
pure virtual

Create new PdsDictionary object.

Parameters
indirectif true the method creates indorect object othervise a direct object.
Returns
newly created PdsDictionary object.

◆ CreateIntObject()

virtual PdsNumber* PdfDoc::CreateIntObject ( bool  indirect,
int  value 
)
pure virtual

Create new PdsNumber (integer) object.

Parameters
indirectif true the method creates indorect object othervise a direct object.
valuethe value to be set to an object.
Returns
newly created PdsNumber object.

◆ CreateNameObject()

virtual PdsName* PdfDoc::CreateNameObject ( bool  indirect,
const wchar_t *  value 
)
pure virtual

Create new PdsName object.

Parameters
indirectif true the methods indorect object othervise a direct object.
valuethe value to be set to an object.
Returns
newly created PdsName object.

◆ CreateNumberObject()

virtual PdsNumber* PdfDoc::CreateNumberObject ( bool  indirect,
double  value 
)
pure virtual

Create new PdsNumber (float) object.

Parameters
indirectif true the method creates indorect object othervise a direct object.
valuethe value to be set to an object.
Returns
newly created PdsNumber object.

◆ CreatePdsObject()

virtual PdsObject* PdfDoc::CreatePdsObject ( PdfObjectType  type,
bool  indirect 
)
pure virtual

Creates a new PdsObject associated with the specified document.

Parameters
typeThe type of a new object.
indirectIf true, creates the object as an indirect object. If false, creates the object as a direct object.
Returns
The newly created object.

◆ CreateStreamObject()

virtual PdsStream* PdfDoc::CreateStreamObject ( bool  indirect,
PdsDictionary dict,
_in_ const uint8_t *  buffer,
int  size 
)
pure virtual

Create new PdsStream object.

Parameters
indirectif true the method creates indorect object othervise a direct object.
dictthe stream dictionary object.
bufferdata to be set a a stream value.
sizethe size of the buffer in bytes.
Returns
newly created PdsStream object.

◆ CreateStringObject()

virtual PdsString* PdfDoc::CreateStringObject ( bool  indirect,
const wchar_t *  value,
bool  hex 
)
pure virtual

Create new PdsString object.

Parameters
indirectif true the method creates indorect object othervise a direct object.
valuethe value to be set to an object.
Returns
newly created PdsString object.

◆ CreateStructTree()

virtual PdsStructTree* PdfDoc::CreateStructTree ( )
pure virtual

Creates the Struct Tree root object of the document. If PdfDoc already has a StructTree it returns the existing structure tree.


Returns
PdsStructTree object that represents document struct tree root.

◆ EmbedFonts()

virtual bool PdfDoc::EmbedFonts ( bool  subset,
_callback_ PdfCancelProc  cancel_proc,
void *  cancel_data 
)
pure virtual

Embeds or subsets fonts used in the document.

Parameters
subsetIf true, embeds each font inside doc with creating a subset.
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.
Returns
true if the was embedded successfully
See also
PdfDoc::AddFontMissingUnicode

◆ FlattenAnnots()

virtual bool PdfDoc::FlattenAnnots ( PdfFlattenAnnotsParams params)
pure virtual

Flatten annotation appearances to the document content and removes flattened annotation from the page


Returns
true if annotation flattening was successfull, false othervise.

◆ GetBookmarkRoot()

virtual PdfBookmark* PdfDoc::GetBookmarkRoot ( )
pure virtual

Gets the abstract root of the document's bookmark tree. This bookmark has no representation in PDF, it only holds top level of document's bookmarks. NOTE: Call only PdfBookmark::GetNumChildren and PdfBookmark::GetChild methods for this bookmark. Other methods return false.


Returns
The document's root bookmark. Sample GetBookmarks

◆ GetCalculatedFormField()

virtual PdfFormField* PdfDoc::GetCalculatedFormField ( int  index)
pure virtual

Gets the calculated form field from AcroForm calculation order array (CO) by index.

Parameters
indexThe index of a form field to retrieve.
Returns
The PdfFormField object or nullptr in case of error.
See also
PdfDoc::GetNumCalculatedFormFields
PdfDoc::GetNumFormFieldCounts
PdfDoc:GetFormField

◆ GetDocTemplate()

virtual PdfDocTemplate* PdfDoc::GetDocTemplate ( )
pure virtual

Accesses document template.

Parameters
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.
Returns
true if successfull, false otherwise.

◆ GetDocumentJavaScript()

virtual int PdfDoc::GetDocumentJavaScript ( int  index,
_out_ wchar_t *  buffer,
int  len 
)
pure virtual

Gets the document JavaScript action by it's index in th documente JavaScript name tree.

Parameters
indexThe index of a JavaScript action name to retrieve
buffer(filled by method) If the buffer is null function returns required length of string
lenLength of a buffer to be filled in.
Returns
Number of characters written into buffer of required length.
See also
PdfDoc::GetNumDocumentJavaScripts
PdfDoc::GetDocumentJavaScriptName

◆ GetDocumentJavaScriptName()

virtual int PdfDoc::GetDocumentJavaScriptName ( int  index,
_out_ wchar_t *  buffer,
int  len 
)
pure virtual

Gets the document JavaScript action name by it's index in th documente JavaScript name tree.

Parameters
indexThe index of a JavaScript action name to retrieve
buffer(filled by method) If the buffer is null function returns required length of string
lenLength of a buffer to be filled in.
Returns
Number of characters written into buffer of required length.
See also
PdfDoc::GetNumDocumentJavaScripts
PdfDoc::GetDocumentJavaScript

◆ GetFormField()

virtual PdfFormField* PdfDoc::GetFormField ( int  index)
pure virtual

Gets the form field in document's AcroForm Fields tree by index.

Returns
The PdfFormField object or nullptr in case of error.
See also
PdfDoc::GetNumCalculatedFormFields
PdfDoc::GetCalculatedFormField
PdfDoc::GetNumFormFieldCounts

◆ GetFormFieldByName()

virtual PdfFormField* PdfDoc::GetFormFieldByName ( const wchar_t *  buffer)
pure virtual

Gets the form field in document's AcroForm Fields tree by name.

Returns
The PdfFormField object or nullptr in case of error.
See also
PdfDoc::GetNumCalculatedFormFields
PdfDoc::GetCalculatedFormField
PdfDoc::GetNumFormFieldCounts

◆ GetInfo()

virtual int PdfDoc::GetInfo ( const wchar_t *  key,
_out_ wchar_t *  buffer,
int  len 
)
pure virtual

Gets the value of a key in a document's Info dictionary.

Parameters
keyThe name of the Info dictionary key whose value is obtained.
buffer(filled by method) If the buffer is null function returns required length of string
lenLength of a buffer to be filled in.
Returns
Number of characters written into buffer of required length.

◆ GetInfoObject()

virtual PdsDictionary* PdfDoc::GetInfoObject ( )
pure virtual

Gets the Info dictionary of the document.

Returns
PdsObject that represents document root.

◆ GetLang()

virtual int PdfDoc::GetLang ( _out_ wchar_t *  buffer,
int  len 
)
pure virtual

Gets documnent primary language.

A language identifier that shall specify the natural language for all text in the document except where overridden by language specifications for structure elements or marked content.

Parameters
buffer(filled by method) If the buffer is null function returns required length of string
lenLength of a buffer to be filled in.
Returns
Number of characters written into buffer of required length.
See also
PdfDoc::SetLang

◆ GetMetadata()

virtual PsMetadata* PdfDoc::GetMetadata ( )
pure virtual

Gets documnent metadata.

Returns
PsMetadata object if metadata was successfully loaded, nullptr otherwise.

◆ GetNumAlternates()

virtual int PdfDoc::GetNumAlternates ( )
pure virtual

Gets the number of PDF alternate in the document.

Returns
The number of alternates.

◆ GetNumCalculatedFormFields()

virtual int PdfDoc::GetNumCalculatedFormFields ( )
pure virtual

Gets the number of calculated form fields in AcroForm calculated order (CO) which is an array.

Returns
Number of calculated form fields in the document.
See also
PdfDoc::GetCalculatedFormField
PdfDoc::GetNumFormFieldCounts
PdfDoc:GetFormField

◆ GetNumDocumentJavaScripts()

virtual int PdfDoc::GetNumDocumentJavaScripts ( )
pure virtual

Gets the number of document JavaScript name/action pairs in the document JavaScript name tree.

Returns
Number document name/action pairs in the document's JavaScript name tree.
See also
PdfDoc::GetDocumentJavaScript
PdfDoc::GetDocumentJavaScriptName

◆ GetNumFormFields()

virtual int PdfDoc::GetNumFormFields ( )
pure virtual

Gets the total number of form fields in document's AcroForm Fields tree.

Returns
Number of form fields in the document.
See also
PdfDoc::GetNumCalculatedFormFields
PdfDoc::GetCalculatedFormField
PdfDoc:GetFormField

◆ GetNumPages()

virtual int PdfDoc::GetNumPages ( )
pure virtual

Gets the number of pages in a document.

Returns
Number of pages in the document.

◆ GetObjectById()

virtual PdsObject* PdfDoc::GetObjectById ( int  obj_id)
pure virtual

Get the document object by number.

Parameters
obj_idThe number of the object to retrieve
Returns
Corresponding object or null if no such object exists in the document

◆ GetRootObject()

virtual PdsDictionary* PdfDoc::GetRootObject ( )
pure virtual

Gets the document catalog dictionary which is a Root entry.

Returns
PdsObject that represents document root.

◆ GetStructTree()

virtual PdsStructTree* PdfDoc::GetStructTree ( )
pure virtual

Gets the Struct Tree root object of the document.

Returns
PdsStructTree object that represents document struct tree root.

◆ MakeAccessible()

virtual bool PdfDoc::MakeAccessible ( PdfAccessibleParams params,
_callback_ PdfCancelProc  cancel_proc,
void *  cancel_data 
)
pure virtual

Makes a PDF document accessible.

Parameters
paramsPdfAccessibleParams parameters that control process of making PDF accessible.
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.
Returns
true if successfull, false otherwise.

◆ RemoveBookmarks()

virtual void PdfDoc::RemoveBookmarks ( )
pure virtual

Removes all bookmarks from the document.

See also
PdfDoc::CreateBookmarks

◆ RemoveStructTree()

virtual void PdfDoc::RemoveStructTree ( )
pure virtual

Removes and destroy the StructTreeRoot element from the specified PdfDoc. This methods doesn't remove marked-content from pages. To do that each page needs to be acquired with CPdfDoc::AcquirePage and marked-content needs to be removed. To be sure that all structural elements were removed, rather call PdfDoc::RemoveTags.


See also
PdfDoc::RemoveTags

◆ RemoveTags()

virtual bool PdfDoc::RemoveTags ( _callback_ PdfCancelProc  cancel_proc,
void *  cancel_data 
)
pure virtual

Remove tags and all structural elements from the document. This method is internally called in CPdfDoc::AddTags method to be sure that all previous tags were removed.


Parameters
cancel_procCallback to check for canceling operations. A CancelProc is typically passed to some method that takes a long time to complete. At frequent intervals, the method calls the CancelProc. If it returns true, then the method cancels its operation; if false, it continues.
cancel_dataPointer to client data for the cancel procedure.

◆ Save()

virtual bool PdfDoc::Save ( const wchar_t *  path,
PdfSaveFlags  flags 
)
pure virtual

Saves a document to the file. NOTE: You must call PdfDoc::Close to release resources.


Parameters
pathAbsolute file path where the document should be saved.
flagsA PdfSaveFlags value. If kSaveIncremental is specified in flags, then path should be NULL. If kSaveFull is specified and path is the same as the file's original path, the new file is saved to a file system-determined temporary path, then the old file is deleted and the new file is renamed to path.
Returns
true if document was saved succsessfully, false otherwise.
See also
PdfDoc::Close

◆ SaveToStream()

virtual bool PdfDoc::SaveToStream ( PsStream stream,
PdfSaveFlags  flags 
)
pure virtual

Saves a document to the stream. NOTE: You must call PdfDoc::Close to release resources.


Parameters
streamThe stream to which the file is saved.
flagsA PdfSaveFlags value. If kSaveIncremental is specified in flags, then path should be NULL. If kSaveFull is specified and path is the same as the file's original path, the new file is saved to a file system-determined temporary path, then the old file is deleted and the new file is renamed to path.
Returns
true if document was saved succsessfully, false otherwise.
See also
PdfDoc::Close

◆ SetInfo()

virtual bool PdfDoc::SetInfo ( const wchar_t *  key,
const wchar_t *  info 
)
pure virtual

Sets the value of a key in a document's Info dictionary.

Parameters
keyThe name of the Info dictionary key whose value is obtained.
bufferString value to be set for the specific Info dictionary entry.
Returns
true if optaining the font state was succsessfull, false otherwise.

◆ SetLang()

virtual bool PdfDoc::SetLang ( const wchar_t *  lang)
pure virtual

Sets documnent primary language.

Parameters
bufferThe buffer containing document primary buffer
Returns
true if the language was successfully set
See also
PdfDoc::GetLang