Foxit PDF SDK ActiveX User Manual

Programming Guide
Copyright © 2011 Foxit Corporation. All Rights Reserved.
No part of this document can be reproduced, transferred, distributed or stored in any format
without the prior written permission of Foxit.
(http://www.antigrain.com). FreeType2 (freetype2.2.1), Copyright (C) 1996-2001,
2002, 2003, 2004| David Turner, Robert Wilhelm, and Werner Lemberg. LibJPEG (jpeg V6b
27- Mar-1998), Copyright (C) 1991-1998 Independent JPEG Group. ZLib (zlib 1.2.2),
Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler. Little CMS, Copyright (C)
1998-2004 Marti Maria. Kakadu, Copyright (C) 2001, David Taubman, The University of New
South Wales (UNSW). PNG, Copyright (C) 1998-2009 Glenn Randers-Pehrson. LibTIFF,
Copyright (C) 1988-1997 Sam Leffler and Copyright (C) 1991-1997 Silicon Graphics, Inc.
Permission to copy, use, modify, sell and distribute this software is granted provided this
copyright notice appears in all copies. This software is provided "as is" without express or
im-plied warranty, and with no claim as to its suitability for any purpose.
2
Programming Guide
Contents
Overview ......................................................................................................... 9
Tutorials ........................................................................................................ 11
1) Open a PDF File ......................................................................... 11
2) Go to a specific page................................................................... 11
3) Zoom a page ............................................................................... 11
4) Rotate a page .............................................................................. 11
5) Print a PDF document ................................................................. 12
6) Hide or show UI elements ........................................................... 12
7) Iterate the whole outline tree ....................................................... 12
8) Search a PDF document ............................................................. 12
9) *Annotations tools ....................................................................... 12
10)
Foxit PDF SDK ActiveX control ................................................................... 14
Properties ............................................................................................... 14
Methods .................................................................................................. 18
#
Form Application ........................................................................ 12
FilePath ................................................................ ............................. 14
Password ........................................................................................... 14
PageCount ........................................................................................ 14
CurPage ................................ ................................ ............................ 14
Rotate ................................................................................................ 14
Zoomlevel .......................................................................................... 15
CurrentTool ........................................................................................ 15
Printer ................................................................................................ 16
DocumentInfo .................................................................................... 16
*bHasFormFields ............................................................................... 17
*bHighlightFormFields ....................................................................... 17
*FormFieldsHighlightAlpha ................................................................ 17
*FormFieldsHighlightColor ................................................................. 17
ActiveXVersion .................................................................................. 17
1) Open and close PDF File ...................................................... 18
2) Viewing ................................................................................. 20
3) Navigation ............................................................................. 23
4) Search................................................................................... 28
5) Outline................................................................................... 30
6) Save ...................................................................................... 31
7) *Annotation ........................................................................... 31
8) Form ..................................................................................... 32
9) Drawing ................................................................................. 34
10) *Running Javascript .............................................................. 35
11) *HyperLink ............................................................................ 35
12) Others ................................................................................... 36
3
Programming Guide
Events ..................................................................................................... 45
BeforeDraw ....................................................................................... 45
AfterDraw .......................................................................................... 45
OnZoomChange ................................................................................ 45
OnPageChange ................................................................................. 45
OnOpenPassword ............................................................................. 45
*OnHyperLink .................................................................................... 46
OnSearchProgress ............................................................................ 46
OnOpenFile ....................................................................................... 46
OnFilePathInvalidate ......................................................................... 47
OnShowSavePrompt ......................................................................... 47
OnOpenDocument............................................................................. 47
OnCloseDocument ............................................................................ 47
OnDocumentChange ......................................................................... 47
CustomFileGetSize............................................................................ 47
CustomFileGetBlock .......................................................................... 48
*OnContextMenuIndex ...................................................................... 48
OnClick .............................................................................................. 48
OnDbClick ......................................................................................... 48
OnRButtonClick ................................................................................. 49
OnDownLoadFinish ........................................................................... 49
OnErrorOccurred ............................................................................... 49
#FormFieldError ................................................................................ 49
OnUploadFinish ................................................................................. 49
OnTextHyperLink ............................................................................... 50
*OnAddMenuItemAction .................................................................... 50
OnExcuteMenuItem ........................................................................... 50
OnDoGoToRAction ............................................................................ 50
#
PDFForm ..................................................................................................... 52
Method .................................................................................................... 52
AddField ................................ ................................ ............................ 52
RemoveFieldsByName ...................................................................... 52
ExportToFDF ..................................................................................... 53
ImportFromFDF ................................................................................. 53
GetFieldByIndex ................................................................................ 53
GetFieldsCount.................................................................................. 53
RemoveField ..................................................................................... 54
#
PDFFormField ............................................................................................. 55
Properties ............................................................................................... 55
Alignment .......................................................................................... 55
BorderStyle ........................................................................................ 55
BorderWidth....................................................................................... 55
ButtonLayout ..................................................................................... 55
CalcOrderIndex ................................................................................. 56
CharLimit ........................................................................................... 56
4
Programming Guide
DefaultValue ...................................................................................... 56
IsEditable ........................................................................................... 56
Behavior ................................ ................................ ............................ 56
IsHidden ................................ ................................ ............................ 57
IsMultiline .......................................................................................... 57
IsPassword ........................................................................................ 57
IsReadOnly ........................................................................................ 57
IsRequired ......................................................................................... 57
Name ................................................................................................. 58
NoViewFlag ....................................................................................... 58
PrintFlag ............................................................................................ 58
Style................................................................................................... 58
TextFont ............................................................................................. 58
TextSize ............................................................................................. 59
Type ................................................................................................... 59
Value ................................................................................................. 59
Tooltip ................................................................................................ 60
Orientation ......................................................................................... 60
Method .................................................................................................... 60
PopulateListOrComboBox ................................................................. 60
SetBackgroundColor ......................................................................... 60
SetBorderColor .................................................................................. 61
SetForegroundColor .......................................................................... 61
SetButtonCaption .............................................................................. 61
SetButtonIcon .................................................................................... 62
SetExportValues ................................................................................ 62
SetJavaScriptAction .......................................................................... 62
SetResetFormAction ......................................................................... 63
SetSubmitFormAction ........................................................................ 63
GetPageIndex ................................................................................... 64
GetRectTop ....................................................................................... 64
GetRectLeft ....................................................................................... 64
GetRectRight ..................................................................................... 64
GetRectBottom .................................................................................. 65
^ CPDFPageAnnots ..................................................................................... 65
Method .................................................................................................... 65
GetPageAnnots ................................................................................. 65
GetAnnot ........................................................................................... 65
AddAnnot ........................................................................................... 65
RemoveAnnot .................................................................................... 66
GetAnnotIndex .................................................................................. 66
GetAnnotsCount ................................................................................ 66
^CPDFAnnot ................................................................................................. 67
Properties ............................................................................................... 67
Thickness .......................................................................................... 67
5
Programming Guide
BorderStyle ........................................................................................ 67
Color .................................................................................................. 67
LineStartingStyle ................................................................................ 68
LineEndingStyle ................................................................................. 68
FillColor ................................ ................................ ............................. 69
Opacity .............................................................................................. 69
Author ................................................................................................ 69
Subject .............................................................................................. 69
CreationDate ..................................................................................... 69
ModificationDate ................................................................................ 70
Locked ............................................................................................... 70
Print ................................................................................................... 70
ReadOnly .......................................................................................... 70
Description ........................................................................................ 70
Methods .................................................................................................. 71
GetType ............................................................................................. 71
GetSubType ...................................................................................... 71
GetContents ...................................................................................... 71
SetContents ....................................................................................... 71
IsPopupOpen .................................................................................... 71
SetPopupOpen .................................................................................. 72
HasPopup .......................................................................................... 72
GetRect ................................................................ ............................. 72
SetRect .............................................................................................. 72
SetLinkGoToAction ............................................................................ 73
SetLinkURLAction ............................................................................. 73
DoAction ............................................................................................ 73
HasAction .......................................................................................... 73
GetMarkedState................................................................................. 74
SetMarkedState ................................................................................. 74
GetReviewState ................................ ................................................. 74
SetReviewState ................................................................................. 74
GetMigrationState .............................................................................. 75
SetMigrationState .............................................................................. 75
SetStartingPoint ................................................................................. 75
GetStartingPoint ................................................................................ 75
SetEndingPoint .................................................................................. 76
GetEndingPoint ................................................................................. 76
SetMediaPoster ................................................................................. 76
SetMultimedia .................................................................................... 76
SetLinkQuadPoints ............................................................................ 77
SetPolygonVertices ........................................................................... 77
SetPencilVertices............................................................................... 77
AttachFile .......................................................................................... 77
^CPDFormatTool .......................................................................................... 78
6
Programming Guide
Method .................................................................................................... 78
GetFormatTool ................................................................................... 78
SetFontName .................................................................................... 78
GetFontName .................................................................................... 78
SetFontSize ....................................................................................... 79
GetFontSize ...................................................................................... 79
SetFontColor ..................................................................................... 79
GetFontColor ..................................................................................... 79
SetBorderColor .................................................................................. 80
GetBorderColor ................................................................................. 80
SetFillColor ........................................................................................ 80
GetFillColor ....................................................................................... 80
SetFontBold ....................................................................................... 80
GetFontBold ...................................................................................... 81
GetFontBoldEnable ........................................................................... 81
SetFontItalic....................................................................................... 81
GetFontItalic ...................................................................................... 81
GetFontItalicEnable ........................................................................... 82
SetAlign ............................................................................................. 82
GetAlign ............................................................................................. 82
SetCharSpace ................................................................................... 82
GetCharSpace ................................................................................... 83
SetCharHorzScale ............................................................................. 83
GetCharHorzScale ............................................................................ 83
PDFPrinter .................................................................................................... 84
Properties ............................................................................................... 84
PrinterName ...................................................................................... 84
printerRangeMode ............................................................................. 84
printerRangeFrom ............................................................................. 84
printerRangeTo .................................................................................. 84
numOfCopies .................................................................................... 84
Scaling ............................................................................................... 85
AutoRotate......................................................................................... 85
AutoCenter ........................................................................................ 85
Collate ............................................................................................... 85
Rotation ............................................................................................. 85
RangeSubset ..................................................................................... 85
ReversePage ..................................................................................... 86
PageBorder ....................................................................................... 86
Methods .................................................................................................. 86
PrintWithDialog .................................................................................. 86
PrintQuiet .......................................................................................... 86
SetPaperSize .................................................................................... 86
PDFOutline ................................................................................................... 87
Methods .................................................................................................. 87
7
Programming Guide
NavigateOutline ................................................................................. 87
GetOutlineTitle ................................................................................... 87
GetOutLineTitle2 ............................................................................... 87
PDFDocumentInfo ........................................................................................ 88
Properties ............................................................................................... 88
Author ................................................................................................ 88
Subject .............................................................................................. 88
CreatedDate ...................................................................................... 88
ModifiedDate ..................................................................................... 88
Keywords ........................................................................................... 88
Creator .............................................................................................. 88
Producer ............................................................................................ 89
Title .................................................................................................... 89
FindResult .................................................................................................... 90
Methods .................................................................................................. 90
GetFindPageNum .............................................................................. 90
GetFindFileName .............................................................................. 90
GetFindString .................................................................................... 90
8
Programming Guide
Overview
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 version360BA9D0-6B2C-4DE1-A500-0D29AD6F5C2F GUID for professional versionDDFACF72-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.UnLockActiveX(“license_id”,”unlock_code”); FoxitReaderSDK.OpenFile(“testdoc.pdf”,””);
2) Go to a specific page
We will go to the third page of the document
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:
CPDFformField button1 = form1.AddField("button1","button",m_nCurPage,0,0,55,30); button1.SetButtonCaption("N","Normal"); button1.SetButtonCaption("R","Rollover"); button1.SetButtonCaption("D","Down"); button1.SetBehavior("push"); // push;Invert; None; Outline; button1.SetTooltip("reset all form"); button1.SetTextFont("Courier");
12
Programming Guide
button1.SetTextSize(15); button1.SetJavaScriptAction("down","app.alert(\"Mouse Down!\")");
11^Annotation Application
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:
14
Programming Guide
0 (normal); 1 (rotated 90 degrees clockwise); 2 (rotated 180 degrees); 3 (rotated 90 degrees counter-clockwise).
Zoomlevel
Type:
long, read and write
Description:
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”
*“Loupe Tool” *“Magnifier” *“Annot Tool” *“Rectangle Link Tool” *“Quadrilateral Link Tool” *“Arrow Tool” *“Line Tool” *“Dimension Tool” *“Square Tool” *“Rectangle Tool” *“Circle Tool” *“Ellipse Tool” *“Polygon Tool” *“Cloudy Tool”
15
Programming Guide
*“Polyline Tool” *“Pencil Tool” *“Rubber Tool” *“Highlight Tool” *“Underline Tool” *“Strikeout Tool” *“Squiggly Tool” *“Replace Tool” *“Note Tool” *“Push Button Tool” *“Check Box Tool” *“Radio Button Tool” *“Combo Box Tool” *“List Box Tool” *“Text Field Tool” *“Distance Tool” *“Perimeter Tool” *“Area Tool” *“Typewriter” *“CallOut” *Textbox *“Image Tool” *“Sound Tool” *“Movie Tool” *“FileAttachment Tool” *“Attach a file”
And so on.
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.
OpenFtpFile
Open a PDF file from an FTP server.
Prototype:
BOOL OpenFtpFile(BSTR ftpName,BSTR username, BSTR userPassword, long port,BSTR filePath, BSTR filePassword, boolean Passive); Parameter:
ftpName - FTP server name
userName - FTP Username
userPassword - FTP password
port - Port on FTP server
filePath - FTP file Path
filePassword - PDF file password
Passive - Passive or active connection Return value:
One (1) if the PDF file is successfully opened, otherwise it is zero (0).
*UploadCurFileToFTP
Upload the current PDF file to an FTP server Prototype:
BOOL UploadCurFileToFTP(BSTR ftpName, BSTR userName, BSTR userPassword,
long port, BSTR FilePath);
Parameter:
ftpName - FTP server name
userName - FTP Username
userPassword - FTP password
port - Port on FTP server
filePath - FTP file Path Return value:
19
Programming Guide
One (1) if the PDF file is successfully opened, otherwise it is zero (0).
CloseFile
Close the currently loaded PDF file.
Prototype:
Void CloseFile() Parameter:
[None] Return value:
[None]
SetFileStreamOption
Set the file stream option when opening the file. Prototype:
Void SetFileStreamOption(BOOL bFileStream); Parameter:
bFileStream - A BOOL value indicating the file stream option. Return value:
[None] Comment:
Loading the stream contents into memory will improve performance if the file is frequently
accessed. However it will cause more memory consumption.
2) Viewing ShowTitleBar
Show or hide the title bar; Prototype:
void ShowTitleBar(BOOL bShow); Parameters:
bShow - If this parameter is FALSE, the title bar will be invisible.
If this parameter is TRUE, the title bar will be visible.
Return value:
[None]
ShowToolBar
Show or hide the toolbar; Prototype:
void ShowToolBar(BOOL bShow); Parameters:
bShow - If this parameter is FALSE, the toolbar will be invisible.
If this parameter is TRUE, the toolbar will be visible.
Return value:
[None]
20
Programming Guide
ShowToolbarButton
Show or hide the toolbar button Prototype:
void ShowToolBarButton (short nIndex, BOOL bShow) Parameters:
nIndex - The index of the button.
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);
Parameters:
nShowMode - the value can be set as following:
MODE_SINGLE =0. MODE_CONTINUOUS =1.
nFacingCount - Number of columns.
Return value:
[None]
GetLayoutShowMode
Obtain the current layout mode.
Prototype:
Void GetLayoutShowMode(short* pnShowMode, short* pnFacingCount)
Parameters:
pnShowMode - Toggles to the current display mode. pnFacingCount - Toggles to the number of pages that are displayedhorizontally.
Return value:
[None]
SetFacingCoverLeft
When in browser facing mode, this function will set cover page of the PDF document to be
rendered on the left. Prototype: Void SetFacingCoverLeft (BOOL bLeft) Parameters:
bLeft - A BOOL value indicating whether to set cover page to be rendered
on the left.
Return value:
[None]
ShowNavigationPanels
Toggle between the navigation panel Prototype:
BOOL ShowNavigationPanels(BOOL bShow) Parameters:
bShow - TRUE shows the navigation panel, FALSE hides it. Return value:
Returns True if successful, False otherwise.
GetPanelStatus
Obtain the status of navigation panels.
22
Programming Guide
Prototype: BOOL GetPanelStatus() Parameters: [None] Return value: Returns TRUE if the panel is visible, FALSE for else.
EnableToolTip
Toggle between the displaying of Tool Tips. Prototype:
BOOL EnableToolTip (BOOL bEnable) Parameters:
bEnable - TRUE shows the Tool Tips, FALSE hides them Return value:
Returns True if successful, False otherwise.
3) Navigation ExistForwardStack
Detect the existence of next view. Prototype:
BOOL ExistForwardStack (); Parameters :
[None] Return value:
If next view exists, then it will return true. Otherwise, it will return false. Comment:
Quite often, when a user navigates within a PDF file, he would like to go back to a previous
reading point. View is a concept that defines certain reading point or displaying status.
Certain user actions will create new views. For example, if a user turns to a new page, and
then zoom in the page, these two actions will create two new views. A program may call
this group of methods to allow user to jump among different views conveniently.
GoForwardStack
Jump to the next view. Prototype:
Void GoForwardStack (); Parameters:
[None] Return value:
[None]
ExistBackwardStack
Detect the existence of previous view. Prototype:
23
Programming Guide
BOOL ExistBackwardStack (); Parameters:
[None] Return value:
If previous view exists, then it will return true. Otherwise, it will return false.
GoBackwardStack
Jump to previous view, Prototype:
void GoBackwardStack (); Parameters:
[None] Return value:
[None]
SetViewRect
Display a rectangle of current PDF page. Prototype:
Void SetViewRect (float Left, float Top, float Width, float Height); Parameters:
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,
VARIANT* pnPageIndex, VARIANT* pPageX, VARIANT* pPageY);
Parameters:
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.
Prototype:
BOOL ConvertPageCoordToClientCoord (long nPageIndex, float dPageX, float dPageY,
long* pnClientX, long* pnClientY);
Parameters:
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
Return value:
[None]
GetScrollLocationEx
The extension of GetScrollLocation function.
rototype:
void GetScrollLocationEx (VARIANT * HPos, VARIANT * VPos);
Parameters:
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