public class CPDFDocument
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
CPDFDocument.CompressListener |
static interface |
CPDFDocument.ExtractImageListener |
static class |
CPDFDocument.PDFDocMdpP |
static class |
CPDFDocument.PDFDocumentCompressLevel
Options to specify compress level.
|
static class |
CPDFDocument.PDFDocumentEncryptAlgo |
static class |
CPDFDocument.PDFDocumentError
Error types of the opening document
|
static class |
CPDFDocument.PDFDocumentImageMode
Options to specify how a view adjusts its content when its size changes.
|
static class |
CPDFDocument.PDFDocumentPermissions
Document permission.
|
static class |
CPDFDocument.PDFDocumentSaveType
Document save type.
|
static class |
CPDFDocument.PDFDocumentType
PDF/A conformance levels.
|
static interface |
CPDFDocument.SignatureRemoveListener |
Constructor and Description |
---|
CPDFDocument(android.content.Context context)
Creates PDF document by context.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addBookmark(CPDFBookmark bookmark)
Adds bookmark.
|
boolean |
addPage(CPDFPage page,
int index)
Add page to document
|
boolean |
applyRedactions()
Applies redaction annotations in current documentation.
|
boolean |
canSaveIncrementally()
Whether document can be saved incrementally.
|
boolean |
checkOwnerPassword(java.lang.String password)
Whether the owner password is correct.
|
boolean |
checkOwnerUnlocked()
Whether the owner permission is unlocked.
|
boolean |
checkPassword(java.lang.String password,
boolean bOwner)
Whether the password is correct.
|
void |
close()
When the object is no longer in use, call this method to release resources.
|
boolean |
convertType(CPDFDocument.PDFDocumentType documentType)
Converts existing PDF files to PDF/A compliant documents, including PDF/A-1a and PDF/A-1b only.
|
CPDFPage |
copyPage(int pageIndex)
Copy the page at page index
|
static CPDFDocument |
createDocument(android.content.Context context)
Creates a CPDFDocument object with new PDF.
|
CPDFWatermark |
createWatermark(CPDFWatermark.Type type)
Creates watermark, more:
CPDFWatermark . |
boolean |
exchangePage(int firstIndex,
int secondIndex)
Exchanges one page with another.
|
boolean |
exportAnnotations(java.lang.String exportFilePath,
java.lang.String tmpCachePath)
Exports annotations to XFDF document.
|
boolean |
extractImage(java.lang.String filePath,
CPDFDocument.ExtractImageListener listener)
Extract all images of the document.
|
boolean |
extractImage(java.lang.String filePath,
int[] pageArr,
CPDFDocument.ExtractImageListener listener)
Extract images at the specified page index array.
|
boolean |
flattenAllPages(CPDFPage.PDFFlattenOption flattenOption)
Flatten all pages.
|
java.lang.String |
getAbsolutePath()
Gets absolute path of document.
|
CPDFBackground |
getBackground()
Gets the background of the document.
|
CPDFBates |
getBates()
Gets the bates numbers of the document.
|
java.util.List<CPDFBookmark> |
getBookmarks()
Gets bookmark list of document, more:
CPDFBookmark . |
java.lang.String |
getBuildTag()
Gets build tag string of document.
|
android.content.Context |
getContext()
Gets context.
|
long |
getDocPtr() |
CPDFDocument.PDFDocumentEncryptAlgo |
getEncryptAlgorithm() |
java.lang.String |
getFileName()
Gets document name.
|
CPDFHeaderFooter |
getHeaderFooter()
Gets the header & footer of the document.
|
CPDFInfo |
getInfo()
Gets document information, more:
CPDFInfo |
int |
getMajorVersion()
Gets major version string of document.
|
int |
getMinorVersion()
Gets minor version string of document.
|
CPDFOutline |
getOutlineRoot()
Gets outline root of document, more:
CPDFOutline . |
int |
getPageCount()
Gets total count of document pages.
|
java.lang.String |
getPageLabel(int pageIndex)
Gets the page label at the specified index.
|
android.graphics.RectF |
getPageSize(int pageIndex)
Gets page size at the specified index.
|
java.lang.String |
getPassword()
Gets document password.
|
CPDFSignature |
getPdfSignature(CPDFSignatureWidget signatureWidget)
Get the signature of a signature widget.
|
CPDFSignature |
getPdfSignature(int index)
Get the signature at index.
|
CPDFDocument.PDFDocumentPermissions |
getPermissions()
Gets permission status of document, more:
CPDFDocument.PDFDocumentPermissions . |
CPDFDocumentPermissionInfo |
getPermissionsInfo()
Gets permission information of document, more:
CPDFDocumentPermissionInfo |
int |
getReVersion()
Gets revision string of document.
|
int |
getSignatureCount()
Gets the count of signature form in the document
|
CPDFDocument.PDFDocumentType |
getType()
Gets PDF/A conformance levels.
|
android.net.Uri |
getUri()
Gets document URI.
|
CPDFWatermark |
getWatermark(int index)
Gets CPDFWatermark according to index, more:
CPDFWatermark . |
int |
getWatermarkCount()
Gets the count of watermark in the document.
|
boolean |
hasBookmark(int pageIndex)
Whether it has bookmark at the specified index
|
boolean |
hasChanges()
Whether document is modified.
|
boolean |
hasRepaired()
Whether document is repaired.
|
boolean |
importAnnotations(java.lang.String importFilePath,
java.lang.String tmpCachePath)
Import annotations from XFDF document.
|
boolean |
importPages(CPDFDocument otherDocument,
int[] pages,
int insertPosition)
Import page(s) from another document at the specified index point and insert to
insertPosition . |
boolean |
importPages(CPDFDocument otherDocument,
int start,
int end,
int insertPosition)
Import page(s) from another document at the specified index point and insert to
insertPosition . |
int |
indexOfPage(CPDFPage page)
Gets the index number for the specified page.
|
CPDFPage |
insertBlankPage(int pageIndex,
float width,
float height)
Inserts a blank page at the specified index point.
|
CPDFPage |
insertPageWithImage(int pageIndex,
float width,
float height,
int fd)
Inserts a blank page with image at the specified index point.
|
CPDFPage |
insertPageWithImage(int pageIndex,
float width,
float height,
int fd,
CPDFDocument.PDFDocumentImageMode imageMode)
Inserts a blank page with image at the specified index point.
|
CPDFPage |
insertPageWithImagePath(int pageIndex,
float width,
float height,
java.lang.String imagePath)
Inserts a blank page with image at the specified index point.
|
CPDFPage |
insertPageWithImagePath(int pageIndex,
float width,
float height,
java.lang.String imagePath,
CPDFDocument.PDFDocumentImageMode imageMode)
Inserts a blank page with image at the specified index point.
|
boolean |
isCanWrite()
Whether it can write
|
boolean |
isEncrypted()
Whether document is encrypted.
|
boolean |
isImageDoc()
Whether the document is image document.
|
boolean |
isLocked()
Whether the document is locked.
|
boolean |
isValid()
Whether CPDFDocument object is valid, false means CPDFDocument object is released.
|
boolean |
movePage(int fromIndex,
int toIndex)
Moves page.
|
CPDFOutline |
newOutlineRoot()
Creates a new outline root of document.
|
CPDFDocument.PDFDocumentError |
open(java.lang.String absolutePath)
Loads the document
|
CPDFDocument.PDFDocumentError |
open(java.lang.String absolutePath,
java.lang.String password)
Loads the encrypted document.
|
CPDFDocument.PDFDocumentError |
open(android.net.Uri uri)
Loads the document by URI.
|
CPDFDocument.PDFDocumentError |
open(android.net.Uri uri,
java.lang.String password)
Loads the encrypted document by URI.
|
CPDFDocument.PDFDocumentError |
openWithoutPreload(android.os.ParcelFileDescriptor fd,
java.lang.String password)
Loads the document without preloading.
|
CPDFPage |
pageAtIndex(int pageIndex)
Returns a pageIndex object representing the page at index, more:
CPDFPage . |
void |
releaseAllBookmarks()
When TPDFBookmark is no longer in use, release all resource of TPDFBookmark.
|
void |
releaseAllOutlines()
When TPDFOutline is no longer in use, release all resource of TPDFOutline.
|
void |
releaseAllPages()
When CPDFPage is no longer in use, release all resource of CPDFPage.
|
void |
releaseAllWatermarks()
When CPDFWatermark is no longer in use, release all resource of CPDFWatermark.
|
void |
releaseTextEdit()
When CPDFPages is no longer in use, release all resource of CPDFPages.
|
CPDFDocument.PDFDocumentError |
reload()
Reloads document.
|
CPDFDocument.PDFDocumentError |
reload(java.lang.String password)
Reloads encrypted document.
|
boolean |
removeAllAnnotations()
Removes all annotations.
|
boolean |
removeAllFormAnnotations()
Removes all form widgets.
|
boolean |
removeAllSignStamps()
Removes all signature
|
boolean |
removeBookmark(int pageIndex)
Removes the bookmark at the specified index.
|
boolean |
removePages(int[] pageIndexes)
Remove page(s).
|
boolean |
removeSignature(CPDFSignature signature,
boolean isRemoveAP,
CPDFDocument.SignatureRemoveListener listener)
Remove signature.
|
boolean |
renderPageAtIndex(android.graphics.Bitmap bitmap,
int pageIndex,
int width,
int height,
int patchX,
int patchY,
int patchW,
int patchH,
int bgColor,
int alpha,
int rotate,
boolean isDrawAnnot,
boolean isDrawForm)
Render contents of a page to a device independent bitmap.
|
boolean |
renderPageScreenShotAtIndex(android.graphics.Bitmap bitmap,
int pageIndex,
int width,
int height,
int patchX,
int patchY,
int patchW,
int patchH,
int bgColor,
int alpha,
int rotate,
boolean isDrawAnnot,
boolean isDrawForm) |
boolean |
resetAllForm()
Resets all forms.
|
boolean |
save()
Saves the document incrementally.
|
boolean |
save(CPDFDocument.PDFDocumentSaveType saveType)
Saves the document.
|
boolean |
save(CPDFDocument.PDFDocumentSaveType saveType,
boolean fontSubset)
Saves the document.
|
boolean |
save(int fd,
CPDFDocument.PDFDocumentSaveType saveType)
Saves the document.
|
boolean |
save(int fd,
CPDFDocument.PDFDocumentSaveType saveType,
boolean fontSubset)
Saves the document.
|
boolean |
saveAs(java.lang.String absolutePath,
boolean removeSecurity)
Saves document to the specified path after removing permissions.
|
boolean |
saveAs(java.lang.String absolutePath,
boolean removeSecurity,
boolean saveByFile)
Saves document to the specified path after removing permissions.
|
boolean |
saveAs(java.lang.String absolutePath,
boolean removeSecurity,
boolean saveByFile,
boolean fontSubset)
Saves document to the specified path after removing permissions.
|
boolean |
saveAs(android.net.Uri uri,
boolean removeSecurity)
Saves document to the specified URI.
|
boolean |
saveAs(android.net.Uri uri,
boolean removeSecurity,
boolean fontSubset)
Saves document to the specified URI.
|
boolean |
saveAsCompressOptimize(java.lang.String absolutePath,
CPDFDocument.PDFDocumentCompressLevel level,
CPDFDocument.CompressListener listener)
Saves document to the specified path after compressing.
|
boolean |
saveAsCompressOptimize(java.lang.String absolutePath,
int quality) |
boolean |
saveAsCompressOptimize(java.lang.String absolutePath,
int quality,
CPDFDocument.CompressListener listener)
Saves document to the specified path after compressing.
|
boolean |
setEncryptAlgorithm(CPDFDocument.PDFDocumentEncryptAlgo type) |
boolean |
setInfo(CPDFInfo info)
Sets document information, more:
CPDFInfo |
boolean |
setOwnerPassword(java.lang.String password)
Not in use currently
|
boolean |
setPermissionsInfo(CPDFDocumentPermissionInfo info)
Sets permission information of document, more:
CPDFDocumentPermissionInfo . |
boolean |
setUserPassword(java.lang.String password)
Sets user password.
|
boolean |
shouleReloadDocument()
Whether to reload document, true means it needs to call
reload(String) or reload() to reload document. |
boolean |
writeSignature(CPDFSignatureWidget signatureWidget,
java.lang.String savePath,
java.lang.String pkcs12certPath,
java.lang.String password,
java.lang.String location,
java.lang.String reason,
CPDFDocument.PDFDocMdpP type)
Add a signature to document.
|
public CPDFDocument(android.content.Context context)
context
- Context.public long getDocPtr()
public android.content.Context getContext()
public CPDFDocument.PDFDocumentError open(java.lang.String absolutePath)
absolutePath
- Absolute path of document.public CPDFDocument.PDFDocumentError open(java.lang.String absolutePath, java.lang.String password)
absolutePath
- Absolute path of document.password
- Document password.public CPDFDocument.PDFDocumentError open(android.net.Uri uri)
uri
- Document source.public CPDFDocument.PDFDocumentError open(android.net.Uri uri, java.lang.String password)
uri
- Document source.password
- Document password.public CPDFDocument.PDFDocumentError openWithoutPreload(android.os.ParcelFileDescriptor fd, java.lang.String password)
fd
- File descriptor.password
- Document password.public CPDFDocument.PDFDocumentError reload()
public CPDFDocument.PDFDocumentError reload(java.lang.String password)
password
- Document password.public boolean isCanWrite()
public java.lang.String getFileName()
public android.net.Uri getUri()
public java.lang.String getAbsolutePath()
public static CPDFDocument createDocument(android.content.Context context)
context
- Context.public boolean isEncrypted()
public boolean isLocked()
public boolean isImageDoc()
public boolean save() throws CPDFDocumentException
CPDFDocumentException
public boolean save(CPDFDocument.PDFDocumentSaveType saveType) throws CPDFDocumentException
saveType
- Method to save the document.CPDFDocumentException
CPDFDocument.PDFDocumentSaveType
public boolean save(CPDFDocument.PDFDocumentSaveType saveType, boolean fontSubset) throws CPDFDocumentException
saveType
- Method to save the document.fontSubset
- Whether to font subset.CPDFDocumentException
CPDFDocument.PDFDocumentSaveType
public boolean save(int fd, CPDFDocument.PDFDocumentSaveType saveType)
fd
- File descriptor.saveType
- Method to save the document.public boolean save(int fd, CPDFDocument.PDFDocumentSaveType saveType, boolean fontSubset)
fd
- File descriptor.saveType
- Method to save the document.fontSubset
- whether to font subset.public boolean saveAsCompressOptimize(java.lang.String absolutePath, CPDFDocument.PDFDocumentCompressLevel level, CPDFDocument.CompressListener listener) throws CPDFDocumentException
absolutePath
- Absolute path of documentlevel
- compress quality CPDFDocument.PDFDocumentCompressLevel
CPDFDocumentException
public boolean saveAsCompressOptimize(java.lang.String absolutePath, int quality, CPDFDocument.CompressListener listener) throws CPDFDocumentException
absolutePath
- Absolute path of documentquality
- compress quality between 1 ~ 120CPDFDocumentException
public boolean saveAsCompressOptimize(java.lang.String absolutePath, int quality) throws CPDFDocumentException
CPDFDocumentException
public boolean saveAs(java.lang.String absolutePath, boolean removeSecurity) throws CPDFDocumentException
absolutePath
- Absolute path of document.removeSecurity
- Whether to remove password.CPDFDocumentException
public boolean saveAs(java.lang.String absolutePath, boolean removeSecurity, boolean saveByFile) throws CPDFDocumentException
absolutePath
- Absolute path of document.removeSecurity
- Whether to remove password.saveByFile
- Whether to save by FILE, differ from using file descriptor of saveAs(String, boolean)
}.CPDFDocumentException
public boolean saveAs(java.lang.String absolutePath, boolean removeSecurity, boolean saveByFile, boolean fontSubset) throws CPDFDocumentException
absolutePath
- Absolute path of document.removeSecurity
- Whether to remove password.saveByFile
- Whether to save by FILE, differ from using file descriptor of saveAs(String, boolean)
}.fontSubset
- Whether to font subset.CPDFDocumentException
public boolean saveAs(android.net.Uri uri, boolean removeSecurity) throws CPDFDocumentException
uri
- Output source of file.removeSecurity
- Whether to remove password.CPDFDocumentException
public boolean saveAs(android.net.Uri uri, boolean removeSecurity, boolean fontSubset) throws CPDFDocumentException
uri
- Output source of file.removeSecurity
- Whether to remove password.fontSubset
- Whether to font subset.CPDFDocumentException
public CPDFDocument.PDFDocumentPermissions getPermissions()
CPDFDocument.PDFDocumentPermissions
.public boolean checkOwnerUnlocked()
public boolean checkPassword(java.lang.String password, boolean bOwner)
password
- The password to check.bOwner
- Whether it is the owner password.public CPDFDocumentPermissionInfo getPermissionsInfo()
CPDFDocumentPermissionInfo
public boolean setPermissionsInfo(CPDFDocumentPermissionInfo info)
CPDFDocumentPermissionInfo
.info
- Permission information.public CPDFInfo getInfo()
CPDFInfo
public boolean setInfo(CPDFInfo info)
CPDFInfo
public int getMajorVersion()
public int getMinorVersion()
public int getReVersion()
public java.lang.String getBuildTag()
public CPDFOutline getOutlineRoot()
CPDFOutline
.public CPDFOutline newOutlineRoot()
CPDFOutline
.public java.util.List<CPDFBookmark> getBookmarks()
CPDFBookmark
.public boolean hasBookmark(int pageIndex)
pageIndex
- Page numberpublic boolean addBookmark(CPDFBookmark bookmark)
bookmark
- Bookmark object.public boolean removeBookmark(int pageIndex)
pageIndex
- Page index.public java.lang.String getPassword()
public int getPageCount()
public android.graphics.RectF getPageSize(int pageIndex)
pageIndex
- Page index.public java.lang.String getPageLabel(int pageIndex)
pageIndex
- Page index.public CPDFPage pageAtIndex(int pageIndex)
CPDFPage
.pageIndex
- Page index.public CPDFPage copyPage(int pageIndex)
pageIndex
- Page Indexpublic boolean addPage(CPDFPage page, int index)
page
- Page object to add to document.index
- Position to add to.public int indexOfPage(CPDFPage page)
page
- Page object.public boolean removePages(int[] pageIndexes)
pageIndexes
- Page index array.public CPDFPage insertBlankPage(int pageIndex, float width, float height)
pageIndex
- Page index.width
- Page width.height
- Page height.public CPDFPage insertPageWithImage(int pageIndex, float width, float height, int fd)
pageIndex
- Page.width
- Page width.height
- Page height.fd
- File descriptor of image resource.public CPDFPage insertPageWithImage(int pageIndex, float width, float height, int fd, CPDFDocument.PDFDocumentImageMode imageMode)
pageIndex
- Page.width
- Page width.height
- Page height.fd
- File description of image resource.imageMode
- Fill mode.public CPDFPage insertPageWithImagePath(int pageIndex, float width, float height, java.lang.String imagePath)
pageIndex
- Page.width
- Page width.height
- Page height.imagePath
- File path of image resource.public CPDFPage insertPageWithImagePath(int pageIndex, float width, float height, java.lang.String imagePath, CPDFDocument.PDFDocumentImageMode imageMode)
pageIndex
- Page.width
- Page width.height
- Page height.imagePath
- File path of image resource.imageMode
- Fill mode.public boolean importPages(CPDFDocument otherDocument, int start, int end, int insertPosition)
insertPosition
.otherDocument
- Other document.start
- Start page index.end
- End page index.insertPosition
- Insert position.public boolean importPages(CPDFDocument otherDocument, int[] pages, int insertPosition)
insertPosition
.otherDocument
- Other document.pages
- Page index array.insertPosition
- Insert position.public boolean movePage(int fromIndex, int toIndex)
fromIndex
- Source page index.toIndex
- Destination page index.public boolean exchangePage(int firstIndex, int secondIndex)
firstIndex
- The first page index.secondIndex
- The second page index.public boolean renderPageAtIndex(android.graphics.Bitmap bitmap, int pageIndex, int width, int height, int patchX, int patchY, int patchW, int patchH, int bgColor, int alpha, int rotate, boolean isDrawAnnot, boolean isDrawForm)
bitmap
- Handle to the device independent bitmap (as the output buffer).pageIndex
- Page index.width
- Page width.height
- Page height.patchX
- Left pixel position of the display area in bitmap coordinates.patchY
- Top pixel position of the display area in bitmap coordinates.patchW
- Horizontal size (in pixels) for displaying the page.patchH
- Vertical size (in pixels) for displaying the page.bgColor
- Background color of image.alpha
- Background opacity of image.rotate
- Rotation angle.isDrawAnnot
- Whether to draw annotation.isDrawForm
- Whether to draw form.public boolean renderPageScreenShotAtIndex(android.graphics.Bitmap bitmap, int pageIndex, int width, int height, int patchX, int patchY, int patchW, int patchH, int bgColor, int alpha, int rotate, boolean isDrawAnnot, boolean isDrawForm)
public boolean importAnnotations(java.lang.String importFilePath, java.lang.String tmpCachePath)
importFilePath
- Path of XFDF.tmpCachePath
- Cache path.public boolean exportAnnotations(java.lang.String exportFilePath, java.lang.String tmpCachePath)
exportFilePath
- XFDF path.tmpCachePath
- Cache path.public boolean setUserPassword(java.lang.String password)
password
- Password string.public boolean setOwnerPassword(java.lang.String password)
public boolean checkOwnerPassword(java.lang.String password)
password
- Owner password.public boolean setEncryptAlgorithm(CPDFDocument.PDFDocumentEncryptAlgo type)
public CPDFDocument.PDFDocumentEncryptAlgo getEncryptAlgorithm()
public boolean canSaveIncrementally()
public boolean hasRepaired()
public int getWatermarkCount()
public CPDFWatermark getWatermark(int index)
CPDFWatermark
.index
- Watermark index.CPDFWatermark
.CPDFTextWatermark
,
CPDFImageWatermark
public CPDFWatermark createWatermark(CPDFWatermark.Type type)
CPDFWatermark
.type
- Watermark type, more: CPDFWatermark.Type
CPDFWatermark
CPDFTextWatermark
,
CPDFImageWatermark
public CPDFHeaderFooter getHeaderFooter()
CPDFHeaderFooter
public CPDFBackground getBackground()
CPDFBackground
public CPDFBates getBates()
CPDFBates
public boolean flattenAllPages(CPDFPage.PDFFlattenOption flattenOption)
flattenOption
- flatten type, more: CPDFPage.PDFFlattenOption
public boolean applyRedactions()
public boolean removeAllAnnotations()
public boolean removeAllFormAnnotations()
public boolean removeAllSignStamps()
public boolean resetAllForm()
public int getSignatureCount()
public boolean hasChanges()
public void close()
public void releaseAllOutlines()
public void releaseTextEdit()
public void releaseAllWatermarks()
public void releaseAllBookmarks()
public void releaseAllPages()
public boolean isValid()
public boolean shouleReloadDocument()
reload(String)
or reload()
to reload document.public CPDFDocument.PDFDocumentType getType()
public boolean convertType(CPDFDocument.PDFDocumentType documentType)
saveAs(String, boolean)
before conversion. Otherwise the conversion fails.documentType
- PDF/A conformance levels.public CPDFSignature getPdfSignature(int index)
index
- signature index.public boolean removeSignature(CPDFSignature signature, boolean isRemoveAP, CPDFDocument.SignatureRemoveListener listener)
signature
- Signature to remove.isRemoveAP
- Whether removing ap.listener
- The callback after removing the signature.public CPDFSignature getPdfSignature(CPDFSignatureWidget signatureWidget)
signatureWidget
- Signauture widget.public boolean writeSignature(CPDFSignatureWidget signatureWidget, java.lang.String savePath, java.lang.String pkcs12certPath, java.lang.String password, java.lang.String location, java.lang.String reason, CPDFDocument.PDFDocMdpP type)
signatureWidget
- Signature widget.savePath
- Save path for the signature file.pkcs12certPath
- Pkcs12 certificate file path.password
- Pkcs12 certificate file passwordlocation
- The CPU host name or physical location of the signing.reason
- Signature reason.type
- Modify permission type. more:CPDFDocument.PDFDocMdpP
public boolean extractImage(java.lang.String filePath, int[] pageArr, CPDFDocument.ExtractImageListener listener)
filePath
- Extract directory.pageArr
- Page index array.listener
- Extract listener.public boolean extractImage(java.lang.String filePath, CPDFDocument.ExtractImageListener listener)
filePath
- Extract directory.listener
- Extract listener.