public class PDFDocument
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MAGNIFICATION_FIT_ACTUAL |
static java.lang.String |
MAGNIFICATION_FIT_HEIGHT |
static java.lang.String |
MAGNIFICATION_FIT_PAGE |
static java.lang.String |
MAGNIFICATION_FIT_VISIBLE |
static java.lang.String |
MAGNIFICATION_FIT_WIDTH |
static java.lang.String |
PAGELAYOUT_ONECOLUMN |
static java.lang.String |
PAGELAYOUT_SINGLEPAGE |
static java.lang.String |
PAGELAYOUT_TWOCOLUMNLEFT |
static java.lang.String |
PAGELAYOUT_TWOPAGELEFT |
static java.lang.String |
PAGEMODE_FULLSCREEN |
static java.lang.String |
PAGEMODE_USEATTACHMENTS |
static java.lang.String |
PAGEMODE_USENONE |
static java.lang.String |
PAGEMODE_USEOC |
static java.lang.String |
PAGEMODE_USEOUTLINES |
static java.lang.String |
PAGEMODE_USETHUMBS |
Constructor and Description |
---|
PDFDocument()
Creates a blank PDF document.
|
PDFDocument(java.io.InputStream inStream,
IPassword password)
Creates a PDFDocument object from a PDF InputStream.
|
PDFDocument(PDFSource source,
IPassword password)
Create a PDFDocument object using a PDFSource interface.
|
PDFDocument(PDFSource source,
IPassword password,
Activity context)
Create a PDFDocument from a PDFSource.
|
PDFDocument(java.lang.String fileName,
IPassword password)
Loads a PDF document from a file.
|
PDFDocument(java.net.URL url,
IPassword password)
Loads a PDF document from a URL.
|
Modifier and Type | Method and Description |
---|---|
void |
addDocumentListener(DocumentChangeListener listener)
Internal method to keep track of document events.
|
boolean |
addEmbeddedFile(java.io.File file)
Embeds a file into this PDF document.
|
Layer |
addLayer(java.lang.String name,
int initialState)
Creates and returns a PDF layer (Optional Content Group).
|
void |
appendDocument(PDFDocument appendDoc)
Appends a PDF document to this document.
|
PDFPage |
appendNewPage(float pageWidth,
float pageHeight)
Creates and appends a new PDFPage to this document.
|
void |
appendPage(PDFPage page)
Appends a page to this document.
|
void |
calculateNow(FormField source) |
void |
clearSecurity(java.lang.String currentPermissionsPwd)
Clears the security for this document.
|
boolean |
containsJavaScript() |
Bookmark |
createRootBookmark()
Creates a new root bookmark and saves it in the document catalog.
|
void |
deletePage(int pageIndex)
Deletes a page from this document.
|
void |
exportAnnotsAsFDF(java.io.OutputStream outStream)
Export annotations comments to an output stream in FDF format.
|
void |
exportAnnotsAsFDF(java.io.OutputStream outStream,
java.lang.String pathToPDFFile,
java.util.Set<Annotation> annotSet)
Export the set of annotation comments to an output stream in FDF format.
|
void |
exportAnnotsAsFDF(java.lang.String fileName)
Exports annotations comments in FDF format.
|
void |
exportAnnotsAsXFDF(java.io.OutputStream outStream,
java.lang.String pathToPDFFile)
Export annotations comments to an output stream in XFDF format.
|
void |
exportAnnotsAsXFDF(java.io.OutputStream outStream,
java.lang.String pathToPDFFile,
java.util.Set<Annotation> annotSet) |
void |
exportAnnotsAsXFDF(java.lang.String fileName)
Exports annotations comments in XFDF format.
|
void |
fireDocumentEvent(DocumentEvent de) |
void |
flattenFields(boolean paintButtons,
boolean paintNonPrintableFields)
Flattens the pdf form fields.
|
AcroForm |
getAcroForm()
Returns the AcroForm in this document.
|
Destinations |
getDestinations() |
DocumentInfo |
getDocumentInfo()
Returns an object representing the document metadata information (author,
title, etc.).
|
static DocumentInfo |
getDocumentInfo(java.io.InputStream inStream,
IPassword password)
Returns an object representing the document metadata information (author, title, etc.).
|
java.util.Vector<IEmbeddedFile> |
getEmbeddedFiles()
Returns the list of embedded files in the document (annotations attachments are not part of the list).
|
java.lang.String |
getEncryptionAlgorithm()
Returns the name of the encryption algorithm used to encrypt the
document.
|
int |
getEncryptionLength()
Returns an int representing the number of bits used in the encryption
technique.
|
java.io.File |
getFile()
Convenience method that returns the file that the PDF document was loaded
from.
|
java.lang.String |
getFileModifiedID()
Returns the file modified ID.
|
java.lang.String |
getFileOriginalID()
Returns the file original ID.
|
com.qoppa.notes.javascript.obfusc.QJavaScriptHandler |
getJSHandler() |
Layer |
getLayer(int layerIndex)
Returns a particular PDF layer given its index.
|
int |
getLayerCount()
Returns the number of PDF layers in this document.
|
com.qoppa.android.pdfViewer.hiObjects.LayerManager |
getLayerManager() |
java.lang.String |
getName() |
com.qoppa.android.pdf.objectStore.PDFObjectStore |
getObjectStore()
Internal method.
|
PDFPage |
getPage(int pageIndex)
Returns a page in this document.
|
int |
getPageCount()
Returns the number of pages in this document.
|
java.lang.String |
getPDFFileVersion()
Return the PDF file version for the current document.
|
PDFSource |
getPDFSource()
Returns an object representing the source of the PDF content.
|
PDFPermissions |
getPermissions()
Returns the permission object for this document.
|
PrintSettings |
getPrintSettings()
Get the current PrintSettings object.
|
Bookmark |
getRootBookmark()
Returns the 'root' bookmark.
|
java.lang.String |
getText()
Returns the text in the pdf document as a
String . |
java.lang.String |
getText(int pageIndex)
Returns text contained in the specified page of the pdf document as a
String.
|
static java.lang.String |
getVersion()
Returns version string for jPDFProcess.
|
java.util.Vector |
getWords()
Returns all words in the pdf document as a
Vector of
Strings . |
java.util.Vector |
getWords(int pageIndex)
Returns all words contained in the specified page of the pdf document as
a Vector of Strings.
|
boolean |
hasBookmarks() |
boolean |
hasEmptyMandatoryField()
Returns true if the document contains one or more unfilled mandatory fields.
|
boolean |
hasOpenPassword()
Returns a flag indicating whether this document is encrypted with a
'user' password.
|
boolean |
hasPermissionsPassword()
Returns a flag indicating whether this document is encrypted with a
'owner' password.
|
void |
importAnnotsFDF(java.io.InputStream inStream)
Import annotations comments from an input stream in FDF format.
|
void |
importAnnotsFDF(java.lang.String fileName)
Import annotations comments from a file in FDF Format.
|
void |
importAnnotsXFDF(java.io.InputStream inStream)
Import AcroForm field data from an input stream in XML format.
|
void |
importAnnotsXFDF(java.lang.String fileName)
Import Acroform fields data from a file in XML Format.
|
PDFPage |
insertNewPage(float pageWidth,
float pageHeight,
int index)
Creates a new PDFPage and inserts it into the document at the given
position.
|
void |
insertPage(PDFPage page,
int index)
Inserts a page into this document at the given index.
|
boolean |
isCalculate()
Return true if javascript calculations are enabled, false otherwise.
|
boolean |
isDocumentModified()
Returns true if the document has been modified, false otherwise.
|
boolean |
isEncrypted()
Returns a flag indicating whether this document is encrypted.
|
boolean |
isPortfolio()
Returns a flag indicating whether this document is a PDF Portfolio.
|
void |
jsPrompt(Activity context,
boolean runOpenActions) |
void |
movePage(int currentIndex,
int newIndex)
moves an existing page to a new location.
|
void |
removeDocumentListener(DocumentChangeListener listener)
Internal method to keep track of document events.
|
boolean |
removeEmbeddedFile(IEmbeddedFile ef)
Remove a file embedded in this document.
|
void |
saveCopy(java.io.OutputStream outStream)
Saves a copy of this document to an output stream.
|
void |
saveCopy(java.lang.String fileName)
Saves a copy of this document to a file.
|
void |
saveDocument()
Saves this document back to its source, if possible.
|
void |
saveDocument(java.lang.String fileName)
Deprecated.
Please use saveCopy()
|
void |
setCalculate(boolean calculate)
Turn javascript calculations on or off.
|
void |
setContainsJavaScript(boolean containsJs) |
void |
setInitialPage(int pageNumber)
Sets the initial page to display.
|
void |
setIsDocumentModified(boolean isModified)
Sets the document's isModifed flag
|
void |
setJavaScriptHandler(com.qoppa.notes.javascript.obfusc.QJavaScriptHandler handler)
Set the JavaScriptHandler to enable javascript execution.
|
static boolean |
setKey(java.lang.String key)
Deprecated.
This method is deprecated and will be removed in a future version.
|
static boolean |
setKey(java.lang.String key,
Context context)
Method to unlock the production version of the library.
|
void |
setMagnification(java.lang.String magnification)
Sets the magnification at which to display the initial view.
|
void |
setPageLayout(java.lang.String pageLayout)
Changes the value of the page layout key for this document.
|
void |
setPageMode(java.lang.String pageMode)
Changes the value of the page mode viewer preference in the document.
|
void |
setPrintSettings(PrintSettings printSettings)
Set the PrintSettings to be used on the next printout.
|
void |
setSecurity(java.lang.String newPermissionsPwd,
java.lang.String newOpenPwd,
PDFPermissions permissions,
java.lang.String currentPermissionsPwd,
int encryptType)
Sets the security for this document.
|
void |
signDocument(SignatureField signField,
SigningInformation signingInfo,
java.lang.String signedPDF)
Signs this document using the given signature field.
|
boolean |
usePermissionsPassword(java.lang.String password)
Tells the PDFDocument object that the permissions password is known, so
all permissions are granted.
|
public static final java.lang.String MAGNIFICATION_FIT_WIDTH
public static final java.lang.String MAGNIFICATION_FIT_VISIBLE
public static final java.lang.String MAGNIFICATION_FIT_HEIGHT
public static final java.lang.String MAGNIFICATION_FIT_PAGE
public static final java.lang.String MAGNIFICATION_FIT_ACTUAL
public static final java.lang.String PAGEMODE_USENONE
public static final java.lang.String PAGEMODE_USEOUTLINES
public static final java.lang.String PAGEMODE_USETHUMBS
public static final java.lang.String PAGEMODE_FULLSCREEN
public static final java.lang.String PAGEMODE_USEOC
public static final java.lang.String PAGEMODE_USEATTACHMENTS
public static final java.lang.String PAGELAYOUT_SINGLEPAGE
public static final java.lang.String PAGELAYOUT_ONECOLUMN
public static final java.lang.String PAGELAYOUT_TWOCOLUMNLEFT
public static final java.lang.String PAGELAYOUT_TWOPAGELEFT
public PDFDocument(java.net.URL url, IPassword password) throws PDFException
url
- URL pointint to the location of the PDF file.password
- An object that provides passwords to open the document, leave
null if not needed. When working with documents that have no
passwords, the host application should pass null for the value
of this parameter. When documents are known to have passwords,
the host application should pass an instance of the
PDFPassword
class that can
hold a single password or a list of passwords.PDFException
public PDFDocument(java.io.InputStream inStream, IPassword password) throws PDFException
inStream
- InputStream to read the pdf document from.password
- An object that provides passwords to open the document, leave
null if not needed. When working with documents that have no
passwords, the host application should pass null for the value
of this parameter. When documents are known to have passwords,
the host application should pass an instance of the
PDFPassword
class that can
hold a single password or a list of passwords.PDFException
public PDFDocument(java.lang.String fileName, IPassword password) throws PDFException
fileName
- Name of the PDF file.password
- An object that provides passwords to open the document, leave
null if not needed. When working with documents that have no
passwords, the host application should pass null for the value
of this parameter. When documents are known to have passwords,
the host application should pass an instance of the
PDFPassword
class that can
hold a single password or a list of passwords.PDFException
public PDFDocument() throws PDFException
PDFException
public PDFDocument(PDFSource source, IPassword password) throws PDFException
source
- The source of the PDF content.password
- The password, if any, used to open the document. Set to null
if there is no password needed.PDFException
public PDFDocument(PDFSource source, IPassword password, Activity context) throws PDFException
source
- password
- context
- PDFException
public boolean isDocumentModified()
public static DocumentInfo getDocumentInfo(java.io.InputStream inStream, IPassword password) throws PDFException
inStream
- InputStream from which to read the PDF content.password
- Password interface, used in case the document is password protected. If the document
is known not to have a password, this argument can be left null.PDFException
public PDFSource getPDFSource()
public void jsPrompt(Activity context, boolean runOpenActions)
public AcroForm getAcroForm()
public void appendDocument(PDFDocument appendDoc) throws PDFException
appendDoc
- Document to be appended.PDFException
public void appendPage(PDFPage page) throws PDFException
page
- The page to add to the document.PDFException
public void movePage(int currentIndex, int newIndex) throws PDFException
currentIndex
- The current index of the page to move.newIndex
- The location to move the page.PDFException
public void insertPage(PDFPage page, int index) throws PDFException
page
- The page to add to the document.index
- Location where to insert the new page.PDFException
public void deletePage(int pageIndex) throws PDFException
pageIndex
- Index of the page to remove.PDFException
public PDFPage appendNewPage(float pageWidth, float pageHeight) throws PDFException
pageWidth
- Width of the page in 72DPI.pageHeight
- Height of the page in 72DPI.PDFException
public PDFPage insertNewPage(float pageWidth, float pageHeight, int index) throws PDFException
pageWidth
- Width of the page in 72DPI.pageHeight
- Height of the page in 72DPI.PDFException
public void importAnnotsFDF(java.io.InputStream inStream) throws PDFException
inStream
- The input stream in FDF format to read the data from.PDFException
public void importAnnotsFDF(java.lang.String fileName) throws PDFException
fileName
- The name of the FDF file to import the data from.PDFException
public void saveDocument() throws java.io.IOException, PDFException, EncryptionChangedException
java.io.IOException
PDFException
EncryptionChangedException
public void setIsDocumentModified(boolean isModified)
isModified
- The boolan value to set the isModified flag to.public void saveCopy(java.lang.String fileName) throws java.io.IOException, PDFException
fileName
- Name of the file to save the document.java.io.IOException
PDFException
public void saveDocument(java.lang.String fileName) throws java.io.IOException, PDFException
java.io.IOException
PDFException
public void saveCopy(java.io.OutputStream outStream) throws java.io.IOException, PDFException
outStream
- OutputStream where the document will be written to.java.io.IOException
PDFException
public static java.lang.String getVersion()
public PDFPage getPage(int pageIndex)
pageIndex
- Index of the page to return.public int getPageCount()
public java.io.File getFile()
public java.lang.String getName()
public java.lang.String getFileOriginalID()
public java.lang.String getFileModifiedID()
public Layer addLayer(java.lang.String name, int initialState) throws PDFException
name
- The name of the layer. This name will show up on a PDF viewer
to turn the layer on or off.initialState
- The initial visibility state of the layer. This determines
whether the layer will be visible or not when the PDF document
is opened. Valid values for this are Layer.STATE_ON or
Layer.STATE_OFF.PDFException
public void setPrintSettings(PrintSettings printSettings)
printSettings
- Settings to use on the next printout.public void setSecurity(java.lang.String newPermissionsPwd, java.lang.String newOpenPwd, PDFPermissions permissions, java.lang.String currentPermissionsPwd, int encryptType) throws PDFException
newPermissionsPwd
- The document's permissions password.newOpenPwd
- The document's open password.permissions
- Permission object.currentPermissionsPwd
- The current permissions password in the document, if any. This
password is needed to be able to change the passwords and
permissions in a document.encryptType
- - The encryption type to use, this value can be either
PDFPermissions.ENCRYPTION_RC4 or
PDFPermissions.ENCRYPTION_AES.PDFPermissionException
- If currentPermissionsPwd is invalid.PDFException
public void clearSecurity(java.lang.String currentPermissionsPwd) throws PDFException
currentPermissionsPwd
- The current permissions password in the document, if any. This
password is needed to be able to change the passwords and
permissions in a document.PDFPermissionException
- If currentPermissionsPwd is invalid.PDFException
public boolean hasOpenPassword()
public boolean isEncrypted()
public int getEncryptionLength()
public java.lang.String getEncryptionAlgorithm()
public boolean hasPermissionsPassword()
public final PDFPermissions getPermissions()
public PrintSettings getPrintSettings()
public Destinations getDestinations()
public java.lang.String getText() throws PDFException
String
. Pages are
separated with a return char.PDFException
public java.lang.String getText(int pageIndex) throws PDFException
pageIndex
- is the 0 based page number. pageIndex = 0 is the first page of
the document.PDFException
public java.util.Vector getWords() throws PDFException
Vector
of
Strings
.PDFException
public java.util.Vector getWords(int pageIndex) throws PDFException
pageIndex
- is the 0 based page number. pageIndex = 0 is the first page of
the document.PDFException
public int getLayerCount()
public Layer getLayer(int layerIndex)
public com.qoppa.android.pdfViewer.hiObjects.LayerManager getLayerManager()
public void addDocumentListener(DocumentChangeListener listener)
public void removeDocumentListener(DocumentChangeListener listener)
public void fireDocumentEvent(DocumentEvent de)
public DocumentInfo getDocumentInfo()
public java.lang.String getPDFFileVersion()
public void setPageMode(java.lang.String pageMode) throws PDFException
pageMode
- The new page mode. This value has to be one of:PDFException
public void setPageLayout(java.lang.String pageLayout) throws PDFException
pageLayout
- The new page mode. This value has to be one of:PDFException
public void setInitialPage(int pageNumber) throws PDFException
pageNumber
- The page number. Use 0 for first page.PDFException
public void setMagnification(java.lang.String magnification) throws PDFException
magnification
- A string magnification. This value has to be one of:PDFException
public boolean usePermissionsPassword(java.lang.String password) throws PDFException
password
- The permissions passwordPDFException
public com.qoppa.android.pdf.objectStore.PDFObjectStore getObjectStore()
public boolean isPortfolio() throws PDFException
PDFException
public void flattenFields(boolean paintButtons, boolean paintNonPrintableFields) throws PDFException
paintButtons
- Flag to indicate whether push buttons should be painted or not.paintNonPrintableFields
- Flag to indicate whether non-printable fields should be painted or not.PDFException
public static boolean setKey(java.lang.String key)
key
- Production key.public static boolean setKey(java.lang.String key, Context context)
key
- Production key.context
- An application context may be necessary to validate the keypublic boolean hasBookmarks() throws PDFException
PDFException
public Bookmark getRootBookmark() throws PDFException
PDFException
public Bookmark createRootBookmark() throws PDFException
PDFException
public void signDocument(SignatureField signField, SigningInformation signingInfo, java.lang.String signedPDF) throws java.io.IOException, PDFException
signField
- The field to use to sign the document.signingInfo
- Information required to sign the document.java.io.IOException
PDFException
SignatureAppearance
public boolean addEmbeddedFile(java.io.File file) throws java.io.IOException, PDFException
file
- The file to embed in the documentjava.io.IOException
PDFException
public boolean removeEmbeddedFile(IEmbeddedFile ef) throws java.io.IOException, PDFException
ef
- the embedded file to removejava.io.IOException
PDFException
public java.util.Vector<IEmbeddedFile> getEmbeddedFiles()
public void setJavaScriptHandler(com.qoppa.notes.javascript.obfusc.QJavaScriptHandler handler)
handler
- public com.qoppa.notes.javascript.obfusc.QJavaScriptHandler getJSHandler()
public boolean hasEmptyMandatoryField()
public void setContainsJavaScript(boolean containsJs)
public boolean containsJavaScript()
public void exportAnnotsAsFDF(java.io.OutputStream outStream) throws PDFException, java.io.IOException
outStream
- The output stream to write the data to.pathToPDFFile
- is the relative path from the fdf file to the pdf file name. This parameter can be left null.
This parameter is used to fill the pdf file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileNa
The file entry is used when you open an fdf file to be able to locate the corresponding pdf file.
Example of pathToPDFFile ../qoppa/mydirPDFException
java.io.IOException
public void exportAnnotsAsFDF(java.lang.String fileName) throws PDFException
fileName
- The name of the file to export the data to.PDFException
public void exportAnnotsAsFDF(java.io.OutputStream outStream, java.lang.String pathToPDFFile, java.util.Set<Annotation> annotSet) throws PDFException, java.io.IOException
outStream
- The output stream to write the data to.pathToPDFFile
- is the relative path from the FDF file to the PDF file name.
This parameter can be left null. This parameter is used to
fill the PDF file name entry in the FDF file, the file entry
will be set to pathToPDFFile + fileName. The file entry is
used when you open an FDF file to be able to locate the
corresponding PDF file. Example of pathToPDFFile
../qoppa/mydirannotSet
- The list of annotations to export. If annotList is not null,
only the annotations contained in the set will be exported.
Otherwise, all annotations will be exported.PDFException
java.io.IOException
public void calculateNow(FormField source)
public void setCalculate(boolean calculate)
public boolean isCalculate()
public void exportAnnotsAsXFDF(java.lang.String fileName) throws PDFException
fileName
- The name of the file to export the data to.PDFException
public void exportAnnotsAsXFDF(java.io.OutputStream outStream, java.lang.String pathToPDFFile, java.util.Set<Annotation> annotSet) throws PDFException, java.io.IOException
PDFException
java.io.IOException
public void exportAnnotsAsXFDF(java.io.OutputStream outStream, java.lang.String pathToPDFFile) throws PDFException
outStream
- The output stream to write the data to.pathToPDFFile
- is the relative path from the fdf file to the pdf file name. This parameter can be left null.
This parameter is used to fill the pdf file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileNa
The file entry is used when you open an fdf file to be able to locate the corresponding pdf file.
Example of pathToPDFFile ../qoppa/mydirjava.io.IOException
PDFException
public void importAnnotsXFDF(java.io.InputStream inStream) throws PDFException
inStream
- The input stream in XML format to read the data from.PDFException
public void importAnnotsXFDF(java.lang.String fileName) throws PDFException
fileName
- The name of the XML file to import the data from.PDFException