public class PDFDocument
extends java.lang.Object
PDFDocument
represents a PDF document.
The PDFDocument
class defines methods to get information about a
document. There are two display modes for PDF applications: one is
full-screen and the other one is normal screen.
Function
specifies the base
display mode, and function
getDisplayMode()
specifies normal
display mode (non full-screen).getNonFullScreenPageMode()
Display modes tell how PDF document is displayed in the application.
It also defines to get the PDFAttachments
,
PDFMetadata
and other objects.
It can be constructed by the following ways:
Example:
PDFDocument document = PDFDocument.open(FileHandler,byte[]);
PDFDocument document = PDFDocument.create();
PDFAttachments
,
PDFMetadata
,
PDFBookmarkIterator
,
PDFTextSearch
Modifier and Type | Class and Description |
---|---|
static class |
PDFDocument.PDFWrapperData
Class
PDFWrapperData represents a wrapper data. |
Modifier and Type | Field and Description |
---|---|
static int |
DISPLAYMODE_FULLSCREEN
Full-screen mode, with no menu bar, window controls, or any other windows
are visible.
|
static int |
DISPLAYMODE_USEATTACHMENTS
Attachment panels are visible.
|
static int |
DISPLAYMODE_USENONE
Neither document outlines nor thumbnail images are visible.
|
static int |
DISPLAYMODE_USEOC
Optional content group panels are visible.
|
static int |
DISPLAYMODE_USEOUTLINES
Document outlines (bookmarks) are visible.
|
static int |
DISPLAYMODE_USETHUMBS
Thumbnail images are visible.
|
static int |
ENCRYPTTYPE_CERTIFICATE
Encrypt type: digital certificate.
|
static int |
ENCRYPTTYPE_CUSTOM
Encrypt type: customized encryption function.
|
static int |
ENCRYPTTYPE_FOXITDRM
Encrypt type: Foxit Corporation's DRM.
|
static int |
ENCRYPTTYPE_NOENCRYPT
No encrypt patterns.
|
static int |
ENCRYPTTYPE_PASSWORD
Encrypt type: password.
|
static int |
ENCRYPTTYPE_RMS
Encrypt type: Microsoft RMS.
|
static int |
LOADFLAG_NOSTREAMCACHES
If set, when load a PDF document, Foxit PDF SDK will not cache streams.
|
static int |
PASSWORDTYPE_INVALID
The password is invalid.
|
static int |
PASSWORDTYPE_NOPASSWORD
No password is used in PDF document.
|
static int |
PASSWORDTYPE_OWNERPASSWORD
An owner password is used in PDF document.
|
static int |
PASSWORDTYPE_USERPASSWORD
A user password is used in PDF document.
|
static int |
PERMISSION_ANNOTFORM
Bit 6.
|
static int |
PERMISSION_ASSEMBLE
Bit 11.
|
static int |
PERMISSION_EXTRACT
Bit 5.
|
static int |
PERMISSION_EXTRACTACCESS
Bit 10.
|
static int |
PERMISSION_FILLFORM
Bit 9.
|
static int |
PERMISSION_MODIFY
Bit 4.
|
static int |
PERMISSION_PRINT
Bit 3.
|
static int |
PERMISSION_PRINT_HIGH
Bit 12.
|
static int |
READDIRECT_L2R
Reading direction from left to right.
|
static int |
READDIRECT_R2L
Reading direction from right to left.
|
static int |
SAVEFLAG_INCREMENTAL
Save PDF document incrementally.
|
static int |
SAVEFLAG_LINEARIZED
Save PDF document with linearized.
|
static int |
SAVEFLAG_NOORIGINAL
Save PDF document without original data or unchanged objects.
|
static int |
SAVEFLAG_OBJECTSTREAM
Save PDF document by using object stream, in order to reduce the file size.
|
static int |
SAVEFLAG_REMOVESECURITY
Save PDF document and remove security.
|
static int |
TRIGGER_DOC_DO
A JavaScript action to be performed after opening a document.
|
static int |
TRIGGER_DOC_DP
A JavaScript action to be performed after printing a document.
|
static int |
TRIGGER_DOC_DS
A JavaScript action to be performed after saving a document.
|
static int |
TRIGGER_DOC_WC
A JavaScript action to be performed before closing a document.
|
static int |
TRIGGER_DOC_WP
A JavaScript action to be performed before printing a document.
|
static int |
TRIGGER_DOC_WS
A JavaScript action to be performed before saving a document.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the current document.
|
void |
closePage(PDFPage page)
Release all contents of page and relative resources.
|
int |
countActions(int trigger)
Get document trigger action counts.
|
int |
countPages()
Get the page count of current document.
|
int |
countSignatures()
Count signatures of current PDF document .
|
static PDFDocument |
create()
Create a new
PDFDocument object. |
PDFBookmarkIterator |
createBookmarkIterator()
Create a new
PDFBookmarkIterator object in the current document. |
PDFForm |
createForm()
Create a
PDFForm object. |
LayerContext |
createLayerContext(int usType)
Create a PDF layer context with a given type.
|
PDFPage |
createPage(int pageIndex)
Create a new page.
|
void |
deletePage(PDFPage page)
Delete a page from document.
|
boolean |
doJavaScriptAction(int trigger)
Perform the document javascript which is specified by the trigger.
|
LayerNode |
enumLayers()
Enum all PDF Layers.
|
void |
exportAnnotsToFDF(java.lang.String pdfPath,
FileHandler fdfFile)
Export all the annotations of the document into a FDF file.
|
PDFAction |
getAction(int trigger,
int index)
Get document trigger action.
|
int |
getAreaType(java.lang.String areaItem)
Get the type of area item.
|
int |
getDisplayMode()
Get display mode.
|
java.lang.String |
getEncryptionFilter()
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
and . |
java.lang.String |
getEncryptionParam(java.lang.String key)
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
and . |
EncryptionParams |
getEncryptionParams()
Get encryption parameter object.
|
java.lang.String |
getEncryptionSubFilter()
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
and . |
int |
getEncryptionType()
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
and . |
int |
getFileVersion()
Get file version.
|
long |
getHandle()
Get the document handle.
|
PDFMetadata |
getMetadata()
Get a
PDFMetadata object. |
int |
getNonFullScreenPageMode()
Get display mode for non full-screen mode from viewer preferences.
|
PDFPage |
getPage(int pageIndex)
Get a
PDFPage object with the specified page index. |
int |
getPasswordType()
Get the password type of current document.
|
int |
getPrintCopies()
Get the number of copies to be printed.
|
int[] |
getPrintRanges()
Get page ranges which are allowed to print.
|
java.lang.String |
getPrintScale()
Get page scale.
|
int |
getReadingDirection()
Get reading direction.
|
Signature |
getSignature(int index)
Get the signature by specified index.
|
boolean |
getUIVisibility(java.lang.String uiItem)
Get UI visibility status.
|
int |
getUserPermissions()
Get user permissions.
|
PDFDocument.PDFWrapperData |
getWrapperData()
Get the
PDFWrapperData object of current document. |
long |
getWrapperOffset()
Get wrapper offset.
|
boolean |
hasForm()
Check if the current document has form.
|
void |
importAnnotsFromFDF(FileHandler fdfFile)
Import all the annotations of the document in a FDF file into the
document.
|
void |
initiateJavaScript()
Perform the document javascript when document is opened, defining
JavaScript functions for use by other scripts in the document.
|
void |
insertAction(int trigger,
int index,
PDFAction action)
Insert document trigger action.
|
boolean |
isModified()
Get PDF document modify mark.
|
boolean |
isWrapper()
Check whether the current document is a wrapper document or not.
|
PDFAttachments |
loadAttachments()
Retrieve a
PDFAttachments object. |
PDFForm |
loadForm()
Retrieve a
PDFForm object. |
static PDFDocument |
open(FileHandler file,
byte[] password)
Open an existing PDF document.
|
static PDFDocument |
open(FileHandler file,
byte[] password,
int flag)
Open an existing PDF document, with specific loading flags.
|
java.lang.String |
pageIndexToPageLabel(int index)
Convert a page index to page label.
|
int |
pageLabelToPageIndex(boolean isCase,
java.lang.String label)
Convert a page label to page index.
|
static void |
registerSecurityHandler(java.lang.String filter,
SecurityHandler securityHandler)
Register a custom or RMS security handler to Foxit PDF SDK, enabling access to a PDF document which is protected by customized or RMS security handler.
|
void |
releaseForm()
Release a PDF interactive form object.
|
boolean |
removeAction(int trigger,
int index)
Remove document trigger action.
|
boolean |
removeAllActions(int trigger)
Remove all document trigger actions.
|
void |
reopen(FileHandler file,
byte[] password)
Re-open PDF file.
|
void |
saveAsWrapper(FileHandler file,
PDFDocument.PDFWrapperData data,
int userPermissions,
byte[] ownerPassword)
Save a PDF document as a wrapper file.
|
void |
saveAsWrapperFile(FileHandler file,
PDFDocument.PDFWrapperData data,
int userPermissions,
java.lang.String ownerPassword)
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
saveAsWrapper(FileHandler, PDFWrapperData, int, byte[]) . |
boolean |
setAction(int trigger,
int index,
PDFAction action)
Set document trigger action.
|
void |
setAreaType(java.lang.String uiItem,
int types)
Set the area type in viewer preferences.
|
static void |
setCertificateHandler(CertificateHandler certificateHandler)
Set certificate security handler to Foxit PDF SDK.
|
static void |
setFoxitDRMHandler(FoxitDRMHandler foxitDRMHandler)
Set Foxit DRM security handler to Foxit PDF SDK.
|
void |
setNonFullScreenPageMode(int mode)
Set display mode for non full-screen mode in viewer preferences.
|
void |
setPrintCopies(int copies)
Set the number of copies to be printed.
|
void |
setPrintRanges(int[] pageRanges)
Set the page ranges to be printed.
|
void |
setPrintScale(java.lang.String printScale)
Set page scaling in viewer preferences.
|
void |
setReadingDirection(int direction)
Set reading direction in viewer preferences.
|
void |
setUIVisibility(java.lang.String uiItem,
boolean uiVisible)
Set UI visibility in viewer preferences.
|
Progress |
startEncryption(EncryptionParams params,
FileHandler encryptedFile,
int flag)
Start encryption on a PDF document.
|
static Progress |
startImportPages(PDFDocument dstDoc,
int startIndex,
PDFDocument srcDoc,
int[] pageRanges,
java.lang.String layerName)
To start a progressive process of inserting a range of pages from an
extra source document (or with its layer information) into a target
document.
|
Progress |
startSaveToFile(FileHandler file,
int flag)
Start saving a PDF document to a file in a progressive manner.
|
static void |
unregisterSecurityHandler(java.lang.String filter)
Unregister a custom or RMS security handler from Foxit PDF SDK, which is registered by function
registerSecurityHandler(String, SecurityHandler) . |
public static final int SAVEFLAG_INCREMENTAL
Normally, this flag shouldn't be combined with
.SAVEFLAG_NOORIGINAL
public static final int SAVEFLAG_NOORIGINAL
public static final int SAVEFLAG_REMOVESECURITY
public static final int SAVEFLAG_OBJECTSTREAM
public static final int SAVEFLAG_LINEARIZED
Note:This flag can only be used in function
, and
should not be used together with other saving flag.startSaveToFile(FileHandler, int)
public static final int DISPLAYMODE_USENONE
public static final int DISPLAYMODE_USEOUTLINES
public static final int DISPLAYMODE_USETHUMBS
public static final int DISPLAYMODE_FULLSCREEN
public static final int DISPLAYMODE_USEOC
public static final int DISPLAYMODE_USEATTACHMENTS
public static final int PASSWORDTYPE_INVALID
public static final int PASSWORDTYPE_NOPASSWORD
public static final int PASSWORDTYPE_USERPASSWORD
public static final int PASSWORDTYPE_OWNERPASSWORD
public static final int ENCRYPTTYPE_NOENCRYPT
public static final int ENCRYPTTYPE_PASSWORD
public static final int ENCRYPTTYPE_CERTIFICATE
public static final int ENCRYPTTYPE_FOXITDRM
public static final int ENCRYPTTYPE_CUSTOM
public static final int ENCRYPTTYPE_RMS
public static final int PERMISSION_PRINT
PERMISSION_PRINT_HIGH
.public static final int PERMISSION_MODIFY
public static final int PERMISSION_EXTRACT
public static final int PERMISSION_ANNOTFORM
public static final int PERMISSION_FILLFORM
public static final int PERMISSION_EXTRACTACCESS
public static final int PERMISSION_ASSEMBLE
public static final int PERMISSION_PRINT_HIGH
public static final int READDIRECT_L2R
public static final int READDIRECT_R2L
public static final int TRIGGER_DOC_DO
public static final int TRIGGER_DOC_WC
public static final int TRIGGER_DOC_WS
public static final int TRIGGER_DOC_DS
public static final int TRIGGER_DOC_WP
public static final int TRIGGER_DOC_DP
public static final int LOADFLAG_NOSTREAMCACHES
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.
Function open(FileHandler, byte[])
will cache streams by default.
public static PDFDocument create() throws PDFException
PDFDocument
object.PDFDocument
object. If there's any error, it will
return null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
public long getHandle()
public static PDFDocument open(FileHandler file, byte[] password) throws PDFException
file
- A FileHandler
object which is a file object to be
loaded. File mode of this should not be FileHandler.FILEMODE_TRUNCATE
.password
- A byte array which specifies a password. It can be user password or owner password.
If no password is used, please pass null
.PDFDocument
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public static PDFDocument open(FileHandler file, byte[] password, int flag) throws PDFException
file
- A FileHandler
object which is a file object to be
loaded. File mode of this should not be FileHandler.FILEMODE_TRUNCATE
.password
- A byte array which specifies a password. It can be user password or owner password.
If no password is used, please pass null
.flag
- An integer
value to specify the loading mode.
Please refer to constant definitions
LOADFLAG_XXX
and this can be one of these constants. open(FileHandler, byte[])
.PDFDocument
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public void reopen(FileHandler file, byte[] password) throws PDFException
To be used in the following two scenarios:
file
- A FileHandler
object which is a file object to be
reloaded.password
- A byte array which specifies a password. It can be user
password or owner password. If no password is used, pass
null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public void close() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFPage getPage(int pageIndex) throws PDFException
PDFPage
object with the specified page index.pageIndex
- Index of PDF page. Range: 0 to (pagecount-1).
pagecount
is returned by function
countPages()
.PDFPage
object.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFPage
public int countPages() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void closePage(PDFPage page) throws PDFException
page
- The specified PDFPage
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFPage
public int getPasswordType() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getEncryptionType() throws PDFException
getEncryptionParams()
and EncryptionParams.getType()
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getUserPermissions() throws PDFException
PERMISSION_XXX
and this can be one or a combination of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getDisplayMode() throws PDFException
DISPLAYMODE_XXX
and this should be one of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getFileVersion() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getReadingDirection() throws PDFException
PDFDocument.READDIRECT_XXX
and this should be one of these constants.READDIRECT_L2R
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getPrintScale() throws PDFException
String
object specifies page scale. null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getPrintCopies() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getEncryptionFilter() throws PDFException
getEncryptionParams()
and EncryptionParams.getFilter()
.String
object indicates encryption filter. null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getEncryptionSubFilter() throws PDFException
getEncryptionParams()
and EncryptionParams.getSubFilter()
.String
object indicates encryption sub-filter. null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getEncryptionParam(java.lang.String key) throws PDFException
getEncryptionParams()
and EncryptionParams.getParam(String)
.key
- A String
object indicates a key to the encrypted data.String
object indicates encryption parameter value. null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public EncryptionParams getEncryptionParams() throws PDFException
EncryptionParams
object. null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
EncryptionParams
public PDFDocument.PDFWrapperData getWrapperData() throws PDFException
PDFWrapperData
object of current document.PDFWrapperData
object.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument.PDFWrapperData
public long getWrapperOffset() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isWrapper() throws PDFException
true
if current document is a wrapper document,
false
for else.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFBookmarkIterator createBookmarkIterator() throws PDFException
PDFBookmarkIterator
object in the current document.PDFBookmarkIterator
object which indicates the
root of bookmark in the current document.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFBookmarkIterator
public PDFMetadata getMetadata() throws PDFException
PDFMetadata
object.PDFMetadata
object associated with the document
which is specified by the parameter.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFMetadata
public boolean isModified() throws PDFException
true
if current document is modified, false for
else. If there is any error, it will return false
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String pageIndexToPageLabel(int index) throws PDFException
index
- Page index starts from 0.String
object indicates page label.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int pageLabelToPageIndex(boolean isCase, java.lang.String label) throws PDFException
isCase
- A boolean
value which indicates to use
case-insensitive when its value is true
, or to
use case-sensitive when its value is false
.label
- A page label string.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean getUIVisibility(java.lang.String uiItem) throws PDFException
Define the way that a document to be presented on the screen or to print.
uiItem
- A String
object. Currently it can be one of the
followings:"HideToolbar"
"HideMenubar"
"HideWindowUI"
"FitWindow"
"CenterWindow"
"DisplayDocTitle"
true
if UI is visible, false
for else.false
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getAreaType(java.lang.String areaItem) throws PDFException
areaItem
- A String
object. Currently it can be one of the
followings: "ViewArea"
"ViewClip"
"PrintArea"
"PrintClip"
PDFPage.PAGEBOX_XXXX
for more details.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int getNonFullScreenPageMode() throws PDFException
For normal document display mode, call the function
to retrieve.getDisplayMode()
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFAttachments loadAttachments() throws PDFException
PDFAttachments
object.PDFAttachments
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAttachments
public PDFForm createForm() throws PDFException
PDFForm
object.
If a PDF document already has an arco form, this function will return the
existed acro form object directly, same as function loadForm()
PDFForm
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFForm
public PDFForm loadForm() throws PDFException
PDFForm
object.PDFForm
object.
If PDFForm object don't exist, null
will be returned.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFForm
public boolean hasForm() throws PDFException
boolean
value to indicate whether the current
document has form.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void releaseForm() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public static Progress startImportPages(PDFDocument dstDoc, int startIndex, PDFDocument srcDoc, int[] pageRanges, java.lang.String layerName) throws PDFException
It will take a long time to complete this process with large range of
pages, so Foxit PDF SDK uses a progressive process.
Caller should call function
to continue
processing in steps, and should call function
Progress.continueProgress(int)
to destroy Progress.release()
Progress
object if importing process is done.
If user calls this function and then calls function
to
save PDF file, the saving flag will be converted to
startSaveToFile(FileHandler, int)
.SAVEFLAG_NOORIGINAL
dstDoc
- A PDFDocument
object which specifies the
destination PDF document handle.startIndex
- A page index in parameter dstDoc
where the
imported pages will be inserted. Range: 0 to (pagecount-1).
pagecount
is returned by function
countPages()
.srcDoc
- A PDFDocument
object which specifies the source
PDF document handle.pageRanges
- An integer
array to record the page ranges to be
imported.null
pointer, it means
importing the whole source document. It should be an even
number when pageRanges
isn't null
.layerName
- A String
object which specifies the source
document name or layers' prefix-name. Insert a range of pages
from an extra source document into a target document When the
value is NULL, or, insert a range of pages from an extra
source document with its layer information into a target
document.Progress
object. null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Progress
public Progress startSaveToFile(FileHandler file, int flag) throws PDFException
It will take a long time to save a document with complex or large content, so Foxit PDF SDK uses a progressive process.
file
- A FileHandler
object which specifies another file
used to save the current PDF document object.flag
- An integer
value to specify saving mode. Please
refer to constant definitions
SAVEFLAG_XXX
and this should be one of these constants.Progress
Object. If there's any error, it will be
null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Progress
,
FileHandler
public void saveAsWrapperFile(FileHandler file, PDFDocument.PDFWrapperData data, int userPermissions, java.lang.String ownerPassword) throws PDFException
saveAsWrapper(FileHandler, PDFWrapperData, int, byte[])
.file
- A FileHandler
object. The wrapper document will
be saved into it.data
- A PDFWrapperData
object which contains wrapper
data, if it's null
, no wrapper data is used.userPermissions
- User permissions for the wrapper document. Pass 0xFFFFFFFC if
it needs no special permissions. Please refer to macro
definitions
PERMISSION_XXX
and this can be one or a combination of these constants.ownerPassword
- A String
object which is owner password. If it's
null
, parameter userPermissions
is
ignored.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument.PDFWrapperData
,
FileHandler
public void saveAsWrapper(FileHandler file, PDFDocument.PDFWrapperData data, int userPermissions, byte[] ownerPassword) throws PDFException
file
- A FileHandler
object. The wrapper document will
be saved into it.data
- A PDFWrapperData
object which contains wrapper
data, if it's null
, no wrapper data is used.userPermissions
- User permissions for the wrapper document. Pass 0xFFFFFFFC if
it needs no special permissions. Please refer to macro
definitions
PERMISSION_XXX
and this can be one or a combination of these constants.ownerPassword
- A String
object which is owner password. If it's
null
, parameter userPermissions
is
ignored.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument.PDFWrapperData
,
FileHandler
public boolean setAction(int trigger, int index, PDFAction action) throws PDFException
trigger
- An integer
value for trigger actions of document.
Please refer to constant definitions
TRIGGER_DOC_XXX
and this should be one of these constants.index
- The index of trigger actions of document.action
- A PDFAction
object to be set.true
if set action successfully, else return
false
for not found the specified index.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAction
public void insertAction(int trigger, int index, PDFAction action) throws PDFException
trigger
- An integer
value for trigger actions of document.
Please refer to constant definitions
TRIGGER_DOC_XXX
and this should be one of these constants.index
- The index of trigger actions of document. The document action
will be inserted to the last position, if index
is out of range.action
- A PDFAction
object to be set.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAction
public boolean removeAction(int trigger, int index) throws PDFException
trigger
- An integer
value for trigger actions of document.
Please refer to constant definitions
TRIGGER_DOC_XXX
and this should be one of these constants.index
- The index of trigger actions of document.true
if remove the specified action successfully,
else return false
for not found the specified
action.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean removeAllActions(int trigger) throws PDFException
trigger
- An integer
value for trigger actions of document.
Please refer to constant definitions
TRIGGER_DOC_XXX
and this should be one of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setUIVisibility(java.lang.String uiItem, boolean uiVisible) throws PDFException
Viewer preferences define the way that a document is to be presented on the screen or for printing.
uiItem
- Currently it can be one of the followings:"HideToolbar"
"HideMenubar"
"HideWindowUI"
"FitWindow"
"CenterWindow"
"DisplayDocTitle"
uiVisible
- A boolean
value that specifies the UI visibility.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setNonFullScreenPageMode(int mode) throws PDFException
mode
- An integer
value to indicate display mode. It
should be one of the followings:PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setReadingDirection(int direction) throws PDFException
direction
- An integer
value which specifies reading
direction:READDIRECT_L2R
:
left-to-right reading order.READDIRECT_R2L
:
right-to-left reading order.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setAreaType(java.lang.String uiItem, int types) throws PDFException
Viewer preferences define the way that a document is to be presented on the screen or to print.
uiItem
- Currently it can be one of the followings:"ViewArea"
"ViewClip"
"PrintArea"
"PrintClip"
types
- An integer
value which specifies a page area
type. Please refer to constant definitions
PAGEBOX_XXX
and this
should be one of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setPrintScale(java.lang.String printScale) throws PDFException
Viewer preferences define the way that a document is to be presented on the screen or to print.
printScale
- A String
object which is a page scale. It should
be one of the followings:
"None"
: the print dialog should reflect no
page scaling. "AppDefault"
:
applications should use the current print scaling.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setPrintCopies(int copies) throws PDFException
Viewer preferences define the way that a document is to be presented on the screen or to print.
copies
- An integer
value which specifies the number of
copies to be printed when the print dialog is opened for this
file. Supported values are the integers 2 through 5. Values
outside this range are ignored.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int[] getPrintRanges() throws PDFException
Viewer preferences define the way that a document is to be presented on the screen or to print.
null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setPrintRanges(int[] pageRanges) throws PDFException
Viewer preferences define the way that a document is to be presented on the screen or to print.
pageRanges
- An integer
array to record the page ranges to
print.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFPage createPage(int pageIndex) throws PDFException
pageIndex
- A zero-based index which specifies the position of the created
page in PDF document.
Range: 0 to (pagecount-1). pagecount
is returned by
function countPages()
. If this is out of
range, the new page will be added to the end in PDF document.PDFPage
object that receives a object of the newly
created page. If there's any error, it will be null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFPage
public void deletePage(PDFPage page) throws PDFException
page
- A valid PDFPage
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFPage
public int countActions(int trigger) throws PDFException
trigger
- An integer
value for trigger actions of document.
Please refer to constant definitions
TRIGGER_DOC_XXX
and this should be one of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFAction getAction(int trigger, int index) throws PDFException
trigger
- An integer
value of a trigger action of document.
Please refer to constant definitions
TRIGGER_DOC_XXX
and this should be one of these constants.index
- An integer
value for index trigger actions of
document.PDFAction
object.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFAction
public void initiateJavaScript() throws PDFException
loadForm()
, or
it will return PDFException.ERRCODE_ERROR
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean doJavaScriptAction(int trigger) throws PDFException
loadForm()
and
initiateJavaScript()
, or it will return
PDFException.ERRCODE_ERROR
.trigger
- Type of the trigger event. Please refer to constant
definitions
TRIGGER_DOC_XXX
and this should be one of these constants.true
if done the specified javascript action
successfully, else return false
for not found the
action.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void exportAnnotsToFDF(java.lang.String pdfPath, FileHandler fdfFile) throws PDFException
This function only support the following annotation types:
, Annot.TYPE_TEXT
, Annot.TYPE_FREETEXT
,
Annot.TYPE_LINE
, Annot.TYPE_SQUARE
, Annot.TYPE_CIRCLE
,
Annot.TYPE_POLYGON
, Annot.TYPE_POLYLINE
, Annot.TYPE_HIGHLIGHT
,
Annot.TYPE_UNDERLINE
, Annot.TYPE_SQUIGGLY
, Annot.TYPE_STRIKEOUT
,
Annot.TYPE_STAMP
, Annot.TYPE_CARET
, Annot.TYPE_INK
.Annot.TYPE_FILEATTACHMENT
pdfPath
- A String
object indicates a PDF file path which the FDF
file will be set.fdfFile
- A FileHandler
object which is a file object in
which all the annotations of the document will be exported.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public void importAnnotsFromFDF(FileHandler fdfFile) throws PDFException
If the users call
before this function; users need to call PDFPage.loadAnnots()
first;
then need to call PDFPage.unloadAnnots()
function before calling other functions of annotations.
And this function only support following annotation types:PDFPage.loadAnnots()
, Annot.TYPE_TEXT
, Annot.TYPE_FREETEXT
,
Annot.TYPE_LINE
, Annot.TYPE_SQUARE
, Annot.TYPE_CIRCLE
,
Annot.TYPE_POLYGON
, Annot.TYPE_POLYLINE
, Annot.TYPE_HIGHLIGHT
,
Annot.TYPE_UNDERLINE
, Annot.TYPE_SQUIGGLY
, Annot.TYPE_STRIKEOUT
,
Annot.TYPE_STAMP
, Annot.TYPE_CARET
, Annot.TYPE_INK
.Annot.TYPE_FILEATTACHMENT
fdfFile
- A FileHandler
object which is a file object in
which all the annotations will be imported to the document.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public int countSignatures() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public Signature getSignature(int index) throws PDFException
index
- The input signature index, starting from 0.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.Signature
,
PDFException
public LayerContext createLayerContext(int usType) throws PDFException
It's required to call the function
to release a context when it isn't used anymore.LayerContext.release()
usType
- An integer
value indicating usage type.
It should be one of the followings: LayerContext
object that receives a PDF layer context.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
LayerContext
public LayerNode enumLayers() throws PDFException
LayerNode
object that receives PDF Layers.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
LayerNode
public static void registerSecurityHandler(java.lang.String filter, SecurityHandler securityHandler) throws PDFException
This function is only used for custom encryption and decryption, and RMS encryption and decryption.
If user wants to use custom or RMS security handler, this function must be called first before doing the encryption or decryption.
Once custom or Microsoft RMS encryption or decryption isn't needed any more, function
should be called to unregister current custom or RMS security handler.unregisterSecurityHandler(String)
filter
- A String
object that specifies security filter.securityHandler
- A valid SecurityHandler
object that specifies a custom or RMS security handler.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
SecurityHandler
public static void unregisterSecurityHandler(java.lang.String filter) throws PDFException
registerSecurityHandler(String, SecurityHandler)
.
(About RMS, for current, only support Microsoft RMS.)filter
- A String
object that specifies a security handler's filter.
It should be registered by previous call to the function registerSecurityHandler(String, SecurityHandler)
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public static void setCertificateHandler(CertificateHandler certificateHandler) throws PDFException
certificateHandler
- A CertificateHandler
object which is a certificate handler.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
CertificateHandler
public static void setFoxitDRMHandler(FoxitDRMHandler foxitDRMHandler) throws PDFException
foxitDRMHandler
- A FoxitDRMHandler
object which is a Foxit DRM handler.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FoxitDRMHandler
public Progress startEncryption(EncryptionParams params, FileHandler encryptedFile, int flag) throws PDFException
It will take a long time to encrypt a document with complex or large contents, so Foxit PDF SDK uses a progressive process to do this.
Caller should call function
to continue encrypting in steps,
and should call function Progress.continueProgress(int)
to destroy the Progress.release()
Progress
object if encrypting process is done.
Parameter encryptedFile
object should have writing mode.
If data cannot be written into parameter encryptedFile
object,
will be thrown on calling function PDFException.ERRCODE_ERROR
during the next steps.Progress.continueProgress(int)
params
- A EncryptionParams
object to specify the encryption parameters.
The type of this EncryptionParams
object represents which encryption will be done to current document.encryptedFile
- A FileHandler
object to save encrypted PDF file. It should have writing mode.flag
- An integer
value to specify saving mode used for encryptedFile.
Please refer to constant definitions SAVEFLAG_XXX
and this should be one of these constants except SAVEFLAG_REMOVESECURITY
and SAVEFLAG_LINEARIZED
.Progress
object that receives a handle of progressive process.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Progress
,
FileHandler
,
EncryptionParams