Foxit PDF SDK ActiveX is a visual programming component that offers PDF displaying
capability with minimal resource demand and redistribution size. It can be easily
integrated into a wide range of applications.
Foxit PDF SDK ActiveX uses the same parsing and rendering engine as Foxit Reader.
Therefore it can display PDF files with the same high quality and fast speed as Foxit
Reader.
Compared to the DLL version of Foxit SDK, the ActiveX version is much easier to use and
has much more rich features built inside. A programmer can simply drag and drop the
component into their application and instantly add PDF displaying functionality. In addition,
the ActiveX allows users to navigate, zoom, rotate, scroll and print out PDF documents.
Version 4.0 incorporates Annotation Module and many advanced PDF features. It enables
you to build your own annotations and allows users to fill out, import or export PDF form
data. Version 4.0 also introduces more functions and events, giving programmers flexible
control over the component and more access to the PDF documents.
Foxit offers two versions of ActiveX 4.0 (standard and professional), which are provided
with different GUID numbers that allows you to register both versions onto the same
computer and access them with their own GUID. Compared with the professional version,
the standard version doesn’t include the following features: creating/editing annotation,
importing/exporting form data, running JavaScript, converting PDF to text, etc. Based on
your requirement needs you are able to pick and choose which ActiveX 4.0 version would
be best for your application. You can purchase either the standard or professional version
online. For the Form and Annotation Module, please contact sales@foxitsoftware.com for licensing details. In this developer’s guide, all the properties and functions marked with an
asterisk (*) are available only in the professional version, all the properties and functions
marked with an asterisk (#) are available only in the Form Module and all the properties
and functions marked with an asterisk (^) are available only in the Annotation Module.
Foxit PDF SDK ActiveX runs on Windows 95/NT or later. This is a standalone component
and does not require any extra PDF software installed. Please note a user might need to
have administrator rights to register the ActiveX under Windows successfully.
There are several complete demo programs written in different languages, including
Visual Basic, Visual C++, Delphi, showing how to use the properties and methods of the
ActiveX. To download these methods please visit www.foxitsoftware.com.
Based on the professional version, Foxit PDF SDK AcitveX 4.0 adds many new interfaces
to support PDF Form Fields, which will allow users to add, delete, import or export, form
data in their PDF documents. The Form Module is licensed separately from ActiveX 4.0
Professional. If you would like to use this module, please contact us at
9
Programming Guide
sales@foxitsoftware.com.
UNLOCK Code: If you have purchased Foxit PDF SDK ActiveX and received the full
version of the ActiveX and the unlock code, you should call UnLockActiveX or
UnLockActiveXEx functions once inside your program before you call ANY other functions
of the ActiveX. This function is described in the Reference section. You don’t need to call
this function if you just want to evaluate the ActiveX.
GUID for standard version:360BA9D0-6B2C-4DE1-A500-0D29AD6F5C2F
GUID for professional version:DDFACF72-E3B5-4A0B-A71F-F39678A34812
10
Programming Guide
Tutorials
The Foxit SDK ActiveX control comes with a single OCX file. To install it, please use
command "regsvr32 OCX name". You may need to specify the proper path if OCX is not
stored in current directory.
The ActiveX control handles user interface for you. It also supplies multiple properties and
methods so that your application is able to control the ActiveX.
The following is a example, suppose we had already created an ActiveX control called
FoxitReaderSDK.
1) Open a PDF File
We will open a PDF document named “testdoc.pdf”
// NOTE: If you are evaluating ActiveX, you don’t need to unlock it,
// then evaluation marks will be shown on all PDF pages.
// For paid customers, please unlock the ActiveX first.
FoxitReaderSDK.GoToPage(2). //The index of first page is 0.
3) Zoom a page
If you want to show a PDF page with its original size, you can use the following code
in VC:
FoxitReaderSDK.SetZoomLevel(0);
Or
FoxitReaderSDK. SetZoomLevel(100);
If you want to set the zoom factor to 200%, use the following code:
FoxitReaderSDK. SetZoomLevel(200);
For more information, see Function Reference section of this guide.
4) Rotate a page
A PDF page can be displayed in four directions: upright, rotated 90 degree, rotated
180 degree, or rotated 270 degree. To display it in different direction, you only need to
call “SetRotate” () to change the Rotate property.
If you want to rotate the page (90 degrees) clockwise, you can use the following code
in VC:
FoxitReaderSDK. SetRotate(1);
11
Programming Guide
5) Print a PDF document
What you need to do is call “PrintWithDialog” method, a print dialog will pop up
and you will be able to specify parameters and then print out the PDF document. If
you want to print without popping up a dialog, you need to use the PDFPrinter
interface.
6) Hide or show UI elements
You can call “ShowToolBar” to show or hide the toolbar. Likewise, you may call
“ShowBookmark” to show or hide the bookmark panel and call “ShowStatusBar” to
show or hide the status bar. If you prefer to build your own toolbar, you may hide the
built-in ActiveX toolbar and then create your own outside the ActiveX.
7) Iterate the whole outline tree
You can call “GetOutlineFirstChild” or“GetOutlineNextSibling” to iterate the
whole outline tree, allowing you to view the outline information from PDFOutline
Interface.
8) Search a PDF document
You can call “FindFirst” to find the first instance of the given text in the whole
document. If no occurrence is found, then the function returns 0. If an occurrence is
found, the function returns a nonzero value and the occurrence will be highlighted.
Select “FindNext” again to search for the next occurrence.
If you want to search for text inside PDF files without opening and displaying
them, you may use the “FindFileFirst”or “FindFileNext”.
9) *Annotations tools
End users can draw lines, circles and other shapes on a PDF document by using
different markup tools. Your application may also change “CurrentTool” property
programmatically, for example, to the “Line Tool”.
10) #Form Application
In version 3.0, Foxit ActiveX provides an interface for PDF forms. By calling
“GetCurrentForm”, you can obtain the IForm interface pointer for the current PDF
document. Then you can use properties and methods in IPDFForm and
IPDFFormField interface classes to perform actions to PDF forms. The following code
shows how to add a form button in a PDF page:
In version 4.0, Foxit ActiveX provides some interfaces to operate Annotation objects.
You can build your own annotations with these interfaces.
13
Programming Guide
Foxit PDF SDK ActiveX control
This section describes all properties and methods exposed by ActiveX. Please note that
the reference shows everything in C syntax. If you use a programming language other than
C/C++, you have to follow the syntax of that language.
Note: The functions marked with the (*) only apply to the professional version, the
functions marked with an asterisk (#) are available only in the Form Module and the
functions marked with an asterisk (^) are available only in the Annotation Module.
Properties
FilePath
Type:
BSTR, read-only
Description:
Full path to the current opened PDF file. If no PDF file is opened or the file is opened from
the buffer or stream,the property is an empty string.
Password
Type:
BSTR, read-only
Description:
Password for the PDF.
PageCount
Type:
long, read-only
Description:
Total number of pages in the current open PDF file.
CurPage
Type:
long, read-only
Description:
Index of the current page of the PDF file. Page index starts from zero for the first page.
Rotate
Type:
short, read and write
Description:
Current rotate orientation, the value can be one of the following:
Normally, the value of this zoom factor is between 10 and 1600. You may also use the
following special values:
0=displaying the page in actual page size, this is the same as setting zoom level to
100%.
1=displaying the page with proper zoom level so that the whole page can be fit into the
client window.
2=displaying the document with proper zoom level so that the width of the page fit to the
client window.
CurrentTool
Type:
BSTR, read and write
Description:
Read and set the current tool. The value can be set to one of following strings:
“Hand Tool”
“ZoomOut Tool”
“ZoomIn Tool”
“Select Text Tool”
“Find Text Tool”
“Snapshot Tool”
You can call CountTools to learn how many tools are available in the current version of
ActiveX, and then call GetToolByIndex to get the tool names.
Printer
Type:
IPDFPrinter, read-only
Description:
Printer property returns an IPDFPrinter interface that you can use for managing the printer
and sending the printout.
DocumentInfo
Type:
IPDFDocumentInfo*, read-only
Description:
DocumentInfo property returns an IPDFDocumentInfo interface with which you can use to
retrieve document information, such as Author, Creator, Creation Date, Keywords, ModDate,
16
Programming Guide
Producer Subject and Title.
*bHasFormFields
Type:
BOOL , read-only
Description:
If current document contains form fields, then bHasFormFields is True; otherwise, it is
False.
*bHighlightFormFields
Type:
BOOL , read and write
Description:
Setting bHighlightFormFields to True will highlight all interactive form fields thereby having
a better visual effects.
*FormFieldsHighlightAlpha
Type:
short, read and write
Description:
Represent 256 levels of transparency of form field highlight color.
0=transparent; 255=opaque.
*FormFieldsHighlightColor
Type:
OLE_COLOR, read and write
Description:
Represent highlight color of form fields.
ActiveXVersion
Type:
BSTR, read-only
Description:
Get the Version info of ActiveX control.
17
Programming Guide
Methods
1) Open and close PDF File
OpenFile
Open a PDF file from a local disk or from an http server.
Prototype:
BOOL OpenFile (BSTR FilePath, BSTR Password)
Parameters:
FilePath - Path to the PDF file or URL to a HTTP server.
Password - Password for the PDF. If no password, specify an empty string.
Return value:
Non-zero if the PDF file is successfully opened, otherwise it is zero.
Comment:
The file will not be locked if it is opened by this method. It can be opened by other program.
OpenMemFile
Open a PDF file that is stored in memory.
Prototype:
BOOL OpenMemFile(long pBuffer, long Size, BSTR Password)
Parameters:
pBuffer - Caller-supplied pointer to a buffer containing PDF data .
Size - Size of the buffer pointed to by pBuffer.
Password - Password for the PDF. If no password, specify an empty string.
Return value:
Nonzero if the PDF file is successfully opened, otherwise it is zero.
OpenBuffer
Open a PDF file from the buffer.
Prototype:
BOOL OpenBuffer(VARIANT Buffer, long size, BSTR password);
Parameters:
Buffer - Byte array containing the PDF.
Size - Size of the byte array.
Password - Password to open the PDF document
Return value:
Nonzero if the PDF file is successfully opened, otherwise it is zero.
OpenStream
Open a PDF file from the IStream interface..
Prototype:
BOOL OpenStream (IStream* Stream, BSTR Password)
Parameters:
Stream - An IStream interface.
Password - Password for the PDF. If no password, specify an empty string.
18
Programming Guide
Return value:
Nonzero if the PDF file is successfully opened, otherwise it is zero.
OpenCustomFile
Open a PDF document from a custom access descriptor. When your program calls this
method, ActiveX will trigger the CustomFileGetSize and CustomFileGetBlock events.
Inside the event handler, your program will open the PDF document from a custom format;
return the file size and block of data. See the description of CustomFileGetSize and
CustomFileGetBlock for more details.
Prototype:
BOOL OpenCustomFile(BSTR Password)
Parameter:
Password - Password for the PDF. If no password, specify an empty string.
Return value:
Non-zero if the PDF file is successfully opened, otherwise it is zero.
bShow - If this parameter is FALSE, the toolbar button will be invisible.
If this parameter is TRUE, the toolbar button will be visible.
Return value:
[None]
ShowStatusBar
Show or hide the status bar
Prototype:
void ShowStatusBar(BOOL bShow);
Parameters:
bShow - If this parameter is FALSE, the Status Bar will be invisible.
If this parameter is TRUE, the Status Bar will be visible.
Return value:
[None]
ShowNavPanelByString
Show a navigation panel by its name.
Prototype:
BOOL ShowNavPanelByString(LPCTSTR lpszPanelName)
Parameters:
lpszPanelName - The panel name, including Bookmark panel, Pages panel,
Layer panel, and Attachments panel.
Return Value:
Returns True if successful, False otherwise.
*ShowFormFieldsMessageBar
Show or hide the FormFieldsMessageBar.
Prototype:
void ShowFormFieldsMessageBar(BOOL bShow)
Parameters:
bShow - If this parameter is FALSE, the FormFieldsMessageBar will be invisible.
If this parameter is TRUE, the FormFieldsMessageBar will be visible.
Return value:
[None]
SetLayoutShowMode
Set the page layout. A PDF document can be displayed as n columns by m rows. No matter
what the facing count number is, when the page layout is set to MODE_SINGLE, the
21
Programming Guide
ActiveX window will display one row at a time, when the page layout is set to
MODE_CONTINUOUS, the window will be able to display adjacent rows at the same time.
Prototype:
Void SetLayoutShowMode (BrowseMode nShowMode, short nFacingCount);
Left - The horizontal coordinate of the top left corner.
Top - The vertical coordinate of the top left corner.
Width - The width of the rectangle.
Height - The height of the rectangle.
Return value:
[None]
Comment:
This function will show a rectangle of current PDF page. The coordinate here is PDF
coordinate, not device coordinate. And the unit is PDF point. The function will keep the
position and size of ActiveX window unchanged and adjust the position and the zoom
factor of current PDF page so that the designate rectangle of current PDF page will be
shown fully inside the ActiveX window. A typical application is: the end user use the mouse
to click and drag a rectangle and then release the mouse, the program will call
ConvertClientCoodToPageCood to convert the mouse coordinates into PDF coordinates
and then call SetViewRect to display the specified area in full view.
ConvertClientCoordToPageCoord
Converts a point in ActiveX control window's client co-ordinates into PDF page coordinate.
Prototype:
BOOL ConvertClientCoordToPageCoord (long nClientX, long nClientY,
long* pnPageIndex, float* pPageX, float* pPageY);
Parameters:
nClientX - X coordinate in the ActiveX control window's client
co-ordinates, in pixels
24
Programming Guide
nClientY - Y coordinate in the ActiveX control window's client
co-ordinates, in pixels
pnPageIndex - For returning page number in which the given point falls on
pPageX - For returning x coordinate of the point inside the PDF page
(in PDF co-ordinate system)
pPageY - For returning y coordinate of the point inside the PDF page
(in PDF co-ordinate system)
Return value:
Return value indicates whether the conversion is successful. The client area contains the
PDF page being shown as well as some grey background. If the point is located in the grey
background, the conversion will fail.
ConvertClientCoordToPageCoordEx
The extension of ConvertClientCoordToPageCoord function.
Prototype:
BOOL ConvertClientCoordToPageCoordEx (long nClientX, long nClientY,
nClientX - X coordinate in the ActiveX control window's client
co-ordinates, in pixels
nClientY - Y coordinate in the ActiveX control window's client
co-ordinates, in pixels
pnPageIndex - For returning page number on which the given point falls
pPageX - For returning x coordinate of the point inside the PDF page
(in PDF co-ordinate system)
pPageY - For returning y coordinate of the point inside the PDF page
(in PDF co-ordinate system)
Return value:
Return value indicates whether the conversion is successful or not. The client area
contains the PDF page being shown as well as some grey background. If the point is located in
the grey background, the conversion will fail.
ConvertPageCoordToClientCoord
Converts PDF page coordinates to the coordinates inside ActiveX control window's client
area.
nPageIndex - page number
dPageX - X coordinate inside the PDF page (in PDF co-ordinate system)
dPageY - Y coordinate inside the PDF page (in PDF co-ordinate system)
pnClientX - For returning X coordinate in the ActiveX control window's client area. A
25
Programming Guide
negative result indicates that the point is outside the ActiveX control
window's client area.
pnClientY - For returning Y coordinate in the ActiveX control window's client area. A
negative result indicates that the point is outside the ActiveX control
window's client area.
Return value:
Return value indicates whether the conversion is successful. If the document is not opened
properly or if the page number is incorrect, then the return value will be false. Otherwise,
the return value will be true.
GotoPageDest
Go to a specified position in a PDF document.
Prototype:
Void GotoPageDest (ILink_Dest * link_dest);
Parameters:
link_dest - An ILink_Dest interface you get from event OnHyperLink .
Return value:
[None]
GoToPagePos
Go to a specified position in a PDF document.
Prototype:
Void GoToPagePos (long nPageIndex, float PageX, float PageY);
Parameters:
nPageIndex - Index of the page you want to view.
PageX - Specify the x coordinate of the position inside the PDF page
which index is specified by nPageIndex.(in PDF co-ordinate system)
PageY - Specify the y coordinate of the position inside the PDF page
which index is specified by nPageIndex.
Return value:
[None]
GetVisibleLeftTopPage
Get the page number of the view at the top left side
Prototype:
Long GetVisibleLeftTopPage ();
Parameter:
[None]
Return value:
the page index which showed on the left top.
ScrollView
Scroll the current view by dx, dy, the unit is device pixel.
Prototype:
26
Programming Guide
Void ScrollView (long dx, long dy);
Parameters:
dx - The horizontal distance of the scrolling action.
dy - The vertical distance of the scrolling action.
Return value:
[None]
GetScrollLocation
Get the current scroll location in current page.
rototype:
void GetScrollLocation (long *dx, long *dy);
Parameters:
dx - For returning x coordinate of the current scroll location
dy - For returning y coordinate of the current scroll location
HPos - For returning x coordinate of the current location you scroll to
VPos - For returning y coordinate of the current location you scroll to
Return value:
[None]
GoToPage
Goes to the specific page of the currently opened PDF document
Prototype:
void GoToPage( long page_index )
Parameters:
page_index - The specific page number
Return value:
[None]
GoToNextPage
Traverse to the next page of the currently open PDF document.
Prototype:
Void GoToNextPage ();
Parameters:
[None]
Return value:
[None]
27
Loading...
+ 63 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.