Foxit PDF SDK
foxit::addon::xfa::XFADoc Class Reference
Inheritance diagram for foxit::addon::xfa::XFADoc:
foxit::Base

Public Types

enum  EventType { e_EventTypeUnknown = 0, e_EventTypePostPrint = 1, e_EventTypePrePrint = 2 }
 Enumeration for XFA event type. More...
 
enum  ExportDataType { e_ExportDataTypeXML = 0, e_ExportDataTypeStaticXDP = 1, e_ExportDataTypeXDP = 2 }
 Enumeration for the type of exported data. More...
 
enum  Type { e_Dynamic = 0, e_Static = 1, e_XDP = 2 }
 Enumeration for XFA document type. More...
 

Public Member Functions

 XFADoc (const pdf::PDFDoc &document, DocProviderCallback *xfa_doc_provider_handler)
 Constructor. More...
 
 XFADoc (const foxit::pdf::PDFDoc &document)
 Constructor. More...
 
 XFADoc (const XFADoc &other)
 Constructor, with another XFA document object. More...
 
 ~XFADoc ()
 Destructor.
 
bool ExportData (const char *output_file_path, ExportDataType export_type)
 Export data to a file. More...
 
bool ExportData (const wchar_t *output_file_path, ExportDataType export_type)
 Export data to a file. More...
 
void FlattenTo (const char *output_file_path)
 Flatten current XFA document to a file. More...
 
void FlattenTo (const wchar_t *output_file_path)
 Flatten current XFA document to a file. More...
 
void FlattenTo (foxit::common::file::StreamCallback *stream)
 Flatten current XFA document to a file stream. More...
 
XFAPage GetPage (int page_index)
 Get XFA page by index. More...
 
int GetPageCount () const
 Get XFA page count. More...
 
Type GetType () const
 Get the XFA document type. More...
 
XFAWidget GetWidgetByFullName (const WString &full_name)
 Get the XFA widget which matches the specified full name. More...
 
bool ImportData (const char *file_path)
 Import data from an XML or XDP file. More...
 
bool ImportData (const wchar_t *file_path)
 Import data from an XML or XDP file. More...
 
bool IsEmpty () const
 Check whether current object is empty or not. More...
 
void KillFocus ()
 Kill the focus of XFA widget. More...
 
bool operator!= (const XFADoc &other) const
 Not equal operator. More...
 
XFADocoperator= (const XFADoc &other)
 Assign operator. More...
 
bool operator== (const XFADoc &other) const
 Equal operator. More...
 
void ProcessEvent (EventType event_type)
 Process a kind of event for all the XFA widgets in current XFA document. More...
 
void ResetForm ()
 Reset form. More...
 
void SetDocProviderCallback (foxit::addon::xfa::DocProviderCallback *doc_provider_callback)
 Set XFA document provider callback. More...
 
void SetFocus (XFAWidget xfa_widget)
 Set the focus of XFA widget. More...
 
void SetPDFPath (const char *pdf_file_path)
 Set the path of related PDF document. More...
 
void SetPDFPath (const wchar_t *pdf_file_path)
 Set the path of related PDF document. More...
 
common::Progressive StartLoad (common::PauseCallback *pause=0)
 Start to load content for current XFA document. More...
 
- Public Member Functions inherited from foxit::Base
FS_HANDLE Handle () const
 Get the handle of current object. More...
 

Detailed Description

Class XFADoc is constructed from a loaded PDF document object, in order to access XFA content more clearly. User must call common::Library::RegisterXFAAppProviderCallback before using XFA moudle. For a newly constructed XFA object, please remember to call function XFADoc::StartLoad before using other functions in class XFA.
To search among a XFA document, please construct a pdf::TextSearch object with XFADoc object.

See also
pdf::TextSearch

Member Enumeration Documentation

◆ EventType

Enumeration for XFA event type.

Values of this enumeration should be used alone.

Enumerator
e_EventTypeUnknown 

Event type: Unknown.

e_EventTypePostPrint 

This kind of event is triggered just after the rendered form has been sent to the printer, spooler, or output destination.

e_EventTypePrePrint 

This kind of event is triggered just before the rendering for printing begins.

◆ ExportDataType

Enumeration for the type of exported data.

Values of this enumeration should be used alone.

Enumerator
e_ExportDataTypeXML 

Type of exported data: XML.

e_ExportDataTypeStaticXDP 

Type of exported data: Static XDP.

e_ExportDataTypeXDP 

Type of exported data: XDP.

◆ Type

Enumeration for XFA document type.

Values of this enumeration should be used alone.

Enumerator
e_Dynamic 

XFA document type: Dynamic.

e_Static 

XFA document type: Static.

e_XDP 

XFA document type: XDP, as Raw XML data.

Constructor & Destructor Documentation

◆ XFADoc() [1/3]

foxit::addon::xfa::XFADoc::XFADoc ( const pdf::PDFDoc document,
DocProviderCallback xfa_doc_provider_handler 
)

Constructor.

Parameters
[in]documentA valid PDF document. It should has been loaded successfully.
[in]xfa_doc_provider_handlerAn XFA document provider callback object which is implemented by user and based on callback class DocProviderCallback. It should not be NULL. User should ensure this callback object is kept valid until related PDF document is released.
Note
If module "XFA" is not defined in the license information which is used in function common::Library::Initialize, that means user has no right in using XFA related functions and this constructor will throw exception foxit::e_ErrInvalidLicense.

◆ XFADoc() [2/3]

foxit::addon::xfa::XFADoc::XFADoc ( const foxit::pdf::PDFDoc document)

Constructor.

When constructing a XFADoc by this constructor successfully, user must set XFA document provider callback by function XFADoc::SetDocProviderCallback.

Parameters
[in]documentA valid PDF document. It should has been loaded successfully.
Note
If module "XFA" is not defined in the license information which is used in function common::Library::Initialize, that means user has no right in using XFA related functions and this constructor will throw exception foxit::e_ErrInvalidLicense.

◆ XFADoc() [3/3]

foxit::addon::xfa::XFADoc::XFADoc ( const XFADoc other)

Constructor, with another XFA document object.

Parameters
[in]otherAnother XFA document object

Member Function Documentation

◆ ExportData() [1/2]

bool foxit::addon::xfa::XFADoc::ExportData ( const char *  output_file_path,
ExportDataType  export_type 
)

Export data to a file.

Parameters
[in]output_file_pathA file path, to which data will be exported to.
[in]export_typeExport type. Please refer to values starting from XFADoc::e_ExportDataTypeXML and this should be one of these values.
Returns
true means success, while false means failure.

◆ ExportData() [2/2]

bool foxit::addon::xfa::XFADoc::ExportData ( const wchar_t *  output_file_path,
ExportDataType  export_type 
)

Export data to a file.

Parameters
[in]output_file_pathA file path, to which data will be exported to.
[in]export_typeExport type. Please refer to values starting from XFADoc::e_ExportDataTypeXML and this should be one of these values.
Returns
true means success, while false means failure.

◆ FlattenTo() [1/3]

void foxit::addon::xfa::XFADoc::FlattenTo ( const char *  output_file_path)

Flatten current XFA document to a file.

Parameters
[in]output_file_pathA file path, to which the flattening result will be saved.
Returns
None.

◆ FlattenTo() [2/3]

void foxit::addon::xfa::XFADoc::FlattenTo ( const wchar_t *  output_file_path)

Flatten current XFA document to a file.

Parameters
[in]output_file_pathA file path, to which the flattening result will be saved.
Returns
None.

◆ FlattenTo() [3/3]

void foxit::addon::xfa::XFADoc::FlattenTo ( foxit::common::file::StreamCallback stream)

Flatten current XFA document to a file stream.

Parameters
[in]streamA foxit::common::file::StreamCallback object which is implemented by user to save the flattened result.
Returns
None.

◆ GetPage()

XFAPage foxit::addon::xfa::XFADoc::GetPage ( int  page_index)

Get XFA page by index.

Parameters
[in]page_indexThe page index. Valid range: from 0 to (count-1). count is returned by function XFADoc::GetPageCount.
Returns
The XFA page.

◆ GetPageCount()

int foxit::addon::xfa::XFADoc::GetPageCount ( ) const

Get XFA page count.

Returns
Page count.

◆ GetType()

Type foxit::addon::xfa::XFADoc::GetType ( ) const

Get the XFA document type.

Returns
The type of XFA document. Please refer to values starting from XFADoc::e_Dynamic and this would be one of these values.

◆ GetWidgetByFullName()

XFAWidget foxit::addon::xfa::XFADoc::GetWidgetByFullName ( const WString full_name)

Get the XFA widget which matches the specified full name.

Some XFA widgets may cover serveral XFA pages. In this case, this function can only be used to get the first matched XFA widget in XFA document. User can also use function XFAPage::GetWidgetByFullName to get the matched XFA widget in an XFA page.

Parameters
[in]full_nameAn XFA widget's full name. It should not be an empty string. XFA widget's full name can be retrieved by function XFAWidget::GetName with type XFAWidget::e_WidgetNameTypeFullName in previous process.
Returns
An XFA Widget object.

◆ ImportData() [1/2]

bool foxit::addon::xfa::XFADoc::ImportData ( const char *  file_path)

Import data from an XML or XDP file.

Parameters
[in]file_pathA path of a source file, whose data will be imported to current XFA document. It should be XML or XDP file and the file extension should be ".xml" or ".xdp".
Returns
true means success, while false means failure.

◆ ImportData() [2/2]

bool foxit::addon::xfa::XFADoc::ImportData ( const wchar_t *  file_path)

Import data from an XML or XDP file.

Parameters
[in]file_pathA path of a source file, whose data will be imported to current XFA document. It should be XML or XDP file and the file extension should be ".xml" or ".xdp".
Returns
true means success, while false means failure.

◆ IsEmpty()

bool foxit::addon::xfa::XFADoc::IsEmpty ( ) const

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ KillFocus()

void foxit::addon::xfa::XFADoc::KillFocus ( )

Kill the focus of XFA widget.

Returns
None.

◆ operator!=()

bool foxit::addon::xfa::XFADoc::operator!= ( const XFADoc other) const

Not equal operator.

Parameters
[in]otherAnother XFA document object. This function will check if current object is not equal to this one.
Returns
true means not equal, while false means equal.

◆ operator=()

XFADoc& foxit::addon::xfa::XFADoc::operator= ( const XFADoc other)

Assign operator.

Parameters
[in]otherAnother XFA document object, whose value would be assigned to current object.
Returns
Reference to current object itself.

◆ operator==()

bool foxit::addon::xfa::XFADoc::operator== ( const XFADoc other) const

Equal operator.

Parameters
[in]otherAnother XFA document object. This function will check if current object is equal to this one.
Returns
true means equal, while false means not equal.

◆ ProcessEvent()

void foxit::addon::xfa::XFADoc::ProcessEvent ( EventType  event_type)

Process a kind of event for all the XFA widgets in current XFA document.

Parameters
[in]event_typeAn event type. Please refer to values starting from XFADoc::e_EventTypePostPrint and this should be one of these values except XFADoc::e_EventTypeUnknown.
Returns
true means success, while false means failure.

◆ ResetForm()

void foxit::addon::xfa::XFADoc::ResetForm ( )

Reset form.

Returns
None.

◆ SetDocProviderCallback()

void foxit::addon::xfa::XFADoc::SetDocProviderCallback ( foxit::addon::xfa::DocProviderCallback doc_provider_callback)

Set XFA document provider callback.

Parameters
[in]doc_provider_callbackAn XFA document provider callback object which is implemented by user and based on callback class DocProviderCallback. It should not be NULL. User should ensure this callback object is kept valid until related PDF document is released.
Returns
None.

◆ SetFocus()

void foxit::addon::xfa::XFADoc::SetFocus ( XFAWidget  xfa_widget)

Set the focus of XFA widget.

Parameters
[in]xfa_widgetA XFA widget which would be focused.
Returns
None.

◆ SetPDFPath() [1/2]

void foxit::addon::xfa::XFADoc::SetPDFPath ( const char *  pdf_file_path)

Set the path of related PDF document.

The PDF path will be used in function XFADoc::ExportData, to be a part of exported data.

Parameters
[in]pdf_file_pathThe file path of related PDF document. It can be either an absolute path or a relative path. It should not be an empty string.
Returns
None.

◆ SetPDFPath() [2/2]

void foxit::addon::xfa::XFADoc::SetPDFPath ( const wchar_t *  pdf_file_path)

Set the path of related PDF document.

The PDF path will be used in function XFADoc::ExportData, to be a part of exported data.

Parameters
[in]pdf_file_pathThe file path of related PDF document. It can be either an absolute path or a relative path. It should not be an empty string.
Returns
None.

◆ StartLoad()

common::Progressive foxit::addon::xfa::XFADoc::StartLoad ( common::PauseCallback pause = 0)

Start to load content for current XFA document.

It may take a long time to loading XFA content, so this function uses a progressive process to do this.
The related PDF document object has been loaded, but only PDF related contents have been loaded. So, in order to access XFA content, this function should be called to load XFA content.

Parameters
[in]pausePause object which decides if the importing process needs to be paused. This can be NULL which means not to pause during the parsing process. If this is not NULL, it should be a valid pause object implemented by user. Default value: NULL.
Returns
A progressive object. Please check the rate of current progress by function common::Progressive::GetRateOfProgress. If the rate is not 100 yet, call function common::Progressive::Continue to coninue the progress until the progress is finished.