Foxit::PDF::Document Class Reference

Class to access PDF document. More...

Public Member Functions

Boolean Load (Stream^ stream, String^ password, UInt32 loadFlag)
 Load a PDF file. More...
 
Boolean SaveAs (Stream^ stream, UInt32 saveFlags, Pause^ pause)
 Saving a PDF document to another file. More...
 
void Close ()
 Close the loaded PDF document. More...
 
Int32 CountPages ()
 Get page count. More...
 
PageInfoGetPageInfo (Int32 index)
 Quickly get page information by index without loading a page. More...
 
BookmarkGetBookmarkRoot ()
 Get the root bookmark of the whole bookmark tree. More...
 
BookmarkFindBookmark (Bookmark^ startBookmark, String^ title, UInt32 flags)
 Find a bookmark with specific title from a specific bookmark. More...
 
Int32 CountAttachment ()
 Get the count of attachments. More...
 
AttachmentGetAttachment (Int32 index)
 Get a specific attachment. More...
 
AttachmentCreateAttachment (FileInfo^ fileInfo, Int32 index, Boolean isEmbedded)
 Create an attachment object and insert it into current document. More...
 
Boolean RemoveAttachment (Attachment^ attachment)
 Remove an attachment. More...
 
Int32 CountSignatures ()
 Count signatures. More...
 
SignatureGetSignature (Int32 index)
 Get a signature object by index. More...
 
SignatureAddSignature (Page^ page, RectF^ rectangle, UInt32 contentsLength)
 Add an unsigned signature object (without appearance) to a specific position in a PDF page. More...
 
Boolean RemoveSignature (Signature^ signature)
 Remove a signature object. More...
 
Boolean SaveToFile (String^ filePath, UInt32 saveFlags, Pause^ pause)
 Saving a PDF document to a specific file path. More...
 
Boolean LoadFromFilePath (String^ filePath, String^ password, UInt32 loadFlag)
 Load a PDF file with the extra flags from a specific file path. More...
 
PageLoadPage (Int32 index, UInt32 loadFlag, Pause^ pause)
 Get and parse a PDF page. More...
 

Properties

Int64 pointer
 Pointer to a handle of PDF document object. This pointer is not useful outside this SDK. The application should not access the pointer to the handle of the PDF document object directly.
 

Detailed Description

Class to access PDF document.

PDF document can be loaded by function Document::Load or Document::LoadFromFilePath. After loading a PDF document, user can get a PDF page, or access the PDF bookmarks. Function Document::Close should be called to close the loaded PDF document when there is no need to access it any more.

Member Function Documentation

Signature ^ Foxit::PDF::Document::AddSignature ( Page page,
RectF rectangle,
UInt32  contentsLength 
)

Add an unsigned signature object (without appearance) to a specific position in a PDF page.

Parameters
[in]pageA PDF::Page object that specifies the PDF page to add a new unsigned signature object.
[in]rectangleA Foxit::RectF object that specifies the position in the PDF page to add the signature object, in PDF page coordinate system. It should be valid.
[in]contentsLengthThe content length of the signature value, in bytes. It should be a even number and should not be less than 8196. If this value is less than 8196, Foxit PDF SDK would set the length to 8196 by default.
Returns
A PDF::Signature object that receives the newly created unsigned signature object.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means parameter page or paramter rectangle is nullptr, or paramter rectangle is invalid, or parameter contentsLength is above 8196 but is not an even number.
ErrorCode::Conflict means parameter page does not belong to current PDF document.
ErrorCode::OutOfMemory means there is not enough memory or if the memory access is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
void Foxit::PDF::Document::Close ( )

Close the loaded PDF document.

Returns
None.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::InvalidModule means PDF module is not initialized.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Int32 Foxit::PDF::Document::CountAttachment ( )

Get the count of attachments.

Returns
The count of attachments. If there is any error, this function will return 0.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Int32 Foxit::PDF::Document::CountPages ( )

Get page count.

Returns
The count of total pages. If there is any error, this fucntion will return 0.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Int32 Foxit::PDF::Document::CountSignatures ( )

Count signatures.

Returns
The count of signatures.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::OutOfMemory means there is not enough memory or if the memory access is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Attachment ^ Foxit::PDF::Document::CreateAttachment ( FileInfo^  fileInfo,
Int32  index,
Boolean  isEmbedded 
)

Create an attachment object and insert it into current document.

Parameters
[in]fileInfoA FileInfo object that specifies the file to be set to current attachment.
[in]indexIndex of attachment which will be inserted into document. Range: 0 to attachmentCount. attachmentCount is returned by function Document::CountAttachment.
[in]isEmbeddedA boolean value which indicates whether the newly created attachment object is an embedded one or a non-embedded one.
Returns
A PDF::Attachment object that receives the newly created attachment object. If there is any error, this function will return nullptr.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means parameter index is out of range or parameter fileInfo is nullptr.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Bookmark ^ Foxit::PDF::Document::FindBookmark ( Bookmark startBookmark,
String^  title,
UInt32  flags 
)

Find a bookmark with specific title from a specific bookmark.

Parameters
[in]startBookmarkA PDF::Bookmark object that specifies a bookmark, from which the searching will start. But this bookmark will not be compared. User can input root bookmark, a founded bookmark in a previous calling of this function or any other bookmark to this parameter, to start a finding process.
[in]titleA String object that specifies the title of bookmark to be found.
[in]flagsIndicate the find options. 0 means no special finding options. And this flag can be one or combination of the followings:
Returns
A PDF::Bookmark class that receives the found bookmark. If no matched bookmark can be found or there is any error, this function will return nullptr.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::NotFound means no matched bookmark can be found.
ErrorCode::OutOfMemory means there is no enough memory or the memory access is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Attachment ^ Foxit::PDF::Document::GetAttachment ( Int32  index)

Get a specific attachment.

Parameters
[in]indexIndex of attachment. Range: 0 to (attachmentcount-1). attachmentcount is returned by function Document::CountAttachment.
Returns
A PDF::Attachment object that receives the specific attachment. If there is any error, this function will return nullptr.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::NotFound means parameter index is out of range.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Bookmark ^ Foxit::PDF::Document::GetBookmarkRoot ( )

Get the root bookmark of the whole bookmark tree.

Please note that "root bookmark" is an abstract object. It can only have some child bookmarks, but no next sibling bookmarks or data (including bookmark data, destination data, and action data).

Returns
A PDF::Bookmark object that receives the root bookmark. If there is any error, this function will return nullptr.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
PageInfo ^ Foxit::PDF::Document::GetPageInfo ( Int32  index)

Quickly get page information by index without loading a page.

Parameters
[in]indexIndex of PDF page. Range: 0 to (pagecount-1). pagecount is returned by function Document::CountPages.
Returns
The page information, including size and rotation. If there is any error, this function will return nullptr.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::NotFound means the parameter index is out of range.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Signature ^ Foxit::PDF::Document::GetSignature ( Int32  index)

Get a signature object by index.

Parameters
[in]indexA zero-based index of annotation to be got. Range: 0 to (sigCount-1). sigCount is returned by function SignatureManager::CountSignatures.
Returns
A PDF::Signature object that receives the specific signature object.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::NotFound means parameter index is out of range.
ErrorCode::OutOfMemory means there is not enough memory or if the memory access is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Boolean Foxit::PDF::Document::Load ( Stream^  stream,
String^  password,
UInt32  loadFlag 
)

Load a PDF file.

It might take a long time to load a document, especially when a file is corrupted, and this function will try to recover the document contents by scanning the whole file.

Parameters
[in]streamA Stream object that specifies the PDF document to be loaded. Currently, only support FileStream. User should ensure this stream can be read.
[in]passwordA String object that specifies the password, which can be either user password or owner password. Just set nullptr for no password.
[in]loadFlagIndicate the loading options. It should be one of the following values:
  • 0: Cache streams by default.
  • 1: Not to cache streams when loading PDF document.
    Loading stream content into memory will improve performance for frequent access, however, it will also consume a lot of memory space. By not caching streams it may reduce the performance a little bit, but greatly reduce the memory consumption, especially when the file is big.
Returns
A boolean value: true means success, while false means failure.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means the parameter stream is nullptr or loadFlag is invalid.
ErrorCode::InvalidLibrary means failing to initialize library.
ErrorCode::InvalidModule means PDF module is not initialized.
ErrorCode::Format means the parameter stream is not a PDF file.
ErrorCode::File means the function cannot read data from the parameter stream.
ErrorCode::UnknownSecurityHandler means there is an unknown security handler.
ErrorCode::Password means the parameter password is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Boolean Foxit::PDF::Document::LoadFromFilePath ( String^  filePath,
String^  password,
UInt32  loadFlag 
)

Load a PDF file with the extra flags from a specific file path.

Parameters
[in]filePathString to a UTF-8 encoded string that specifies a path of file.
[in]passwordA String object that specifies the password, which can be either user password or owner password. Just set nullptr for no password.
[in]loadFlagIndicate the loading options. It should be one of the following values:
  • 0: Cache streams by default.
  • 0x1: When loading a PDF document, Foxit PDF SDK will not cache streams. Loading stream content into memory will improve performance for frequent access, however, it will also consume a lot of memory space. Not to cache streams may reduce the performance a little bit, but greatly reduce the memory consumption, especially when the file is big.
Returns
A boolean value: true means success, while false means failure.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means the parameter filePath is nullptr or loadFlag is invalid.
ErrorCode::InvalidLibrary means failing to initialize library.
ErrorCode::InvalidModule means PDF module is not initialized.
ErrorCode::Format means the parameter filePath is not a PDF file.
ErrorCode::File means the function cannot read data from the parameter filePath.
ErrorCode::UnknownSecurityHandler means there is an unknown security handler.
ErrorCode::Password means the parameter password is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Page ^ Foxit::PDF::Document::LoadPage ( Int32  index,
UInt32  loadFlag,
Pause pause 
)

Get and parse a PDF page.

Parameters
[in]indexIndex of PDF page. Range: 0 to (pageCount-1). pageCount is returned by function Document::CountPages.
[in]loadFlagPage loading flags. It should be one of the following values:
[in]pause(Reserved, should be nullptr currently) A Foxit::Pause object that specifies the pause control for loading a page in progressive process.
Returns
A PDF::Page object that receives that loaded PDF page. If there is any error, this function will return nullptr.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means parameter parseFlag is invalid.
ErrorCode::NotFound means the parameter index is out of range.
ErrorCode::NotParsed means the document hasn't been parsed successfully when being loaded or reloaded.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Boolean Foxit::PDF::Document::RemoveAttachment ( Attachment attachment)

Remove an attachment.

Parameters
[in]attachmentA PDF::Attachment object which will be removed.
Returns
A boolean value: true means success, while false means failure.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success. And parameter attachment becomes invliad.
ErrorCode::Param means parameter attachment is nullptr or invalid.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Boolean Foxit::PDF::Document::RemoveSignature ( Signature signature)

Remove a signature object.

Parameters
[in]signatureA PDF::Signature object that specifies the signature object to be removed.
Returns
A boolean value: true means success, while false means failure.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means parameter signature is nullptr.
ErrorCode::Conflict means parameter signature does not belong to current PDF document.
ErrorCode::OutOfMemory means there is not enough memory or if the memory access is wrong.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Boolean Foxit::PDF::Document::SaveAs ( Stream^  stream,
UInt32  saveFlags,
Pause pause 
)

Saving a PDF document to another file.

It will take a long time to save a document with complex or large content.

Parameters
[in]streamA Stream object that specifies the PDF document to be saved. Currently, only support FileStream. User should ensure this stream can be written and should close this stream after saving process is finished.
[in]saveFlagsA saving PDF document flag. Please refer to enumeration PDF::SaveFlags and it should be one or a combination of these flags.
[in]pause(Reserved, should be nullptr currently) A Foxit::Pause object that specifies the pause control for saving a PDF document in progressive process.
Returns
A boolean value: true means success, while false means failure.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means the parameter stream is nullptr or saveFlags is invalid.
ErrorCode::InvalidModule means PDF module is not initialized.
ErrorCode::Format means the parameter stream is not a PDF file.
ErrorCode::File means the function cannot read data from the parameter stream.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.
Boolean Foxit::PDF::Document::SaveToFile ( String^  filePath,
UInt32  saveFlags,
Pause pause 
)

Saving a PDF document to a specific file path.

Parameters
[in]filePathA String object that specifies the path of save file.
[in]saveFlagsA saving PDF document flag. Please refer to enumeration PDF::SaveFlags and it should be one or a combination of these flags.
[in]pause(Reserved, should be nullptr currently) A Foxit::Pause object that specifies the pause control for saving a PDF document in progressive process.
Returns
A boolean value: true means success, while false means failure.
Call function Library::GetLastError after this function returns, to get the error code.
ErrorCode::Success means success.
ErrorCode::Param means the parameter filePath is nullptr or saveFlags is invalid.
ErrorCode::InvalidModule means PDF module is not initialized.
ErrorCode::Format means the parameter filePath is not a PDF file.
ErrorCode::File means the function cannot read data from the parameter filePath.
ErrorCode::Error means the function fails because of any other reasons.
For more error code values, please refer to enumeration Foxit::ErrorCode.

Foxit Corporation