Package com.compdfkit.core.document
Class CPDFDocument
java.lang.Object
com.compdfkit.core.document.CPDFDocument
Document instance. One CPDFDocument object for one document. This class is used to represent a specified directory, which contains PDF files and user wants to search among these PDF files.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumError types of the opening documentstatic enumOptions to specify how a view adjusts its content when its size changes.static enumstatic enumDocument save type.static interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd page to documentbooleanaddTable(int pageIndex, int tableWidth, int tableHeight, int positionx, int positiony, int rows, int cols, String[] textArr, PointI[] textPosArr, String[] imageArr, PointI[] imagePosArr) booleanWhether document can be saved incrementally.booleancheckOwnerPassword(String password) voidclose()When the object is no longer in use, call this method to release resources.copyPage(int pageNum) Copy the page at page indexcreateCompare(CPDFDocument compDoc) createCompare(CPDFDocument baseDoc, CPDFDocument compDoc) createCompareDrawings(CPDFDocument compDoc) static CPDFDocumentCreates a CPDFDocument object with new PDF.createWatermarkbooleanexchangePage(int firstIndex, int secondIndex) Exchanges one page with another.booleanexportAnnotations(String exportXPDFPath, String tmpCacheDirPath) Exports annotations to XFDF document.booleanexportCustomWidgets(String exportFilePath, String tmpCachePath, String[] fieldNames) 以xfdf文件格式导出当前文档的所有自定义表单booleanexportWidgets(String exportFilePath, String tmpCachePath) 以xfdf文件格式导出当前文档的表单数据booleanflattenAllPages(CPDFPage.PDFFlattenOption flattenOption) Flatten all pages.Gets build tag string of document.longdocument absolute pathgetInfo()Gets document information, more:CPDFInfointGets major version string of document.intGets minor version string of document.intGets total count of document pages.getPageLabel(int pageNum) Gets the page label at the specified index.getPageSize(int pageNum) Gets page size at the specified index.Gets document password.getPdfSignature(int index) Get the signature of the specified index in the document.Gets permission status of document, more:CPDFDocument.PDFDocumentPermissions.Gets permission information of document, more:CPDFDocumentPermissionInfointGets revision string of document.intGet the total number of signatures in the document.getWatermark(int index) getWatermarkintbooleanWhether document is modified.booleanWhether document is repaired.booleanimportAnnotations(String importXPDFPath) Import annotations from XFDF document.booleanimportAnnotations(String importFilePath, String tmpCachePath) Import annotations from XFDF document.booleanimportCustomWidgets(String importFilePath, String tmpCachePath) 通过xfdf文件导入自定义表单到当前文档booleanimportPages(CPDFDocument otherDocument, int[] pages, int insertPosition) Import page(s) from another document at the specified index point and insert toinsertPosition.booleanimportPages(CPDFDocument otherDocument, int start, int end, int insertPosition) Import page(s) from another document at the specified index point and insert toinsertPosition.booleanimportWidgets(String importFilePath, String cachePath) 导入表单数据intindexOfPage(CPDFPage page) Gets the index number for the specified page.insertBlankPage(int pageIndex, float width, float height) Inserts a blank page at the specified index point.insertPageWithImagePath(int pageNum, float width, float height, String imagePath, CPDFDocument.PDFDocumentImageMode imageMode) Inserts a blank page with image at the specified index point.booleanWhether document is encrypted.booleanisLocked()Whether the document is locked.booleanisValid()Whether CPDFDocument object is valid, false means CPDFDocument object is released.booleanmovePage(int fromIndex, int toIndex) Moves page.Loads the documentLoads the encrypted document.openWithStream(InputStream stream, String password) pageAtIndex(int pageNum) Returns a pageNum object representing the page at index, more:CPDFPage.voidWhen CPDFPage is no longer in use, release all resource of CPDFPage.voidbooleanremoveAllSignStamps(CPDFDocument document, boolean isRemoveAP) Remove all signaturesbooleanremovePages(int[] pageNums) Remove page(s).booleanremoveSignature(CPDFSignature signature, CPDFDocument document, boolean isRemoveAP) Delete signaturebooleansave(CPDFDocument.PDFDocumentSaveType saveType) The doucment has changes, sava file.booleansave(String absolutePath, CPDFDocument.PDFDocumentSaveType saveType) The doucment has changes, sava file.booleanMandatory saving, the principle is to use non-incremental saving as a document to copy the current documentvoidsetDocPtr(long docPtr) booleanSets document information, more:CPDFInfobooleansetOwnerPassword(String password) Not in use currentlybooleanSets permission information of document, more:CPDFDocumentPermissionInfo.booleansetUserPassword(String password) Sets user password.booleanWhether to reload document, true means it needs to call to reload document.booleanwriteSignature(CPDFSignatureWidget signatureWidget, String savePath, String pkcs12certPath, String password, String location, String reason, CPDFDocument.PDFDocMdpP type) Add a signature to document.
-
Constructor Details
-
CPDFDocument
public CPDFDocument()Creates PDF document
-
-
Method Details
-
createDocument
Creates a CPDFDocument object with new PDF.- Returns:
- Document object.
-
setDocPtr
public void setDocPtr(long docPtr) -
isValid
public boolean isValid()Whether CPDFDocument object is valid, false means CPDFDocument object is released.- Returns:
- Returns whether CPDFDocument object is valid.
-
shouleReloadDocument
public boolean shouleReloadDocument()Whether to reload document, true means it needs to call to reload document.- Returns:
- Returns whether to reload document.
-
open
Loads the document- Parameters:
absolutePath- Absolute path of document.- Returns:
- Returns the error type when loading document.
-
open
Loads the encrypted document.- Parameters:
absolutePath- Absolute path of document.password- Document password.- Returns:
- Returns the error type when loading document.
-
openWithStream
-
getPassword
Gets document password.- Returns:
- Returns document password.
-
isEncrypted
public boolean isEncrypted()Whether document is encrypted.- Returns:
- Returns whether document is encrypted.
-
isLocked
public boolean isLocked()Whether the document is locked.- Returns:
- Returns whether the document is locked.
-
getInfo
Gets document information, more:CPDFInfo- Returns:
- Returns document information.
-
setInfo
Sets document information, more:CPDFInfo- Returns:
- Returns true on success, false on failure.
-
getMajorVersion
public int getMajorVersion()Gets major version string of document.- Returns:
- Returns major version string of document.
-
getMinorVersion
public int getMinorVersion()Gets minor version string of document.- Returns:
- Returns minor version string of document.
-
getReVersion
public int getReVersion()Gets revision string of document.- Returns:
- Returns revision string of document.
-
getBuildTag
Gets build tag string of document.- Returns:
- Returns build tag string of document.
-
getPermissions
Gets permission status of document, more:CPDFDocument.PDFDocumentPermissions.- Returns:
- Returns permission status of document.
-
getPermissionsInfo
Gets permission information of document, more:CPDFDocumentPermissionInfo- Returns:
- Returns permissions of document.
-
setPermissionsInfo
Sets permission information of document, more:CPDFDocumentPermissionInfo.- Parameters:
info- Permission information.- Returns:
- Returns whether to successfully set document permission.
-
getPageCount
public int getPageCount()Gets total count of document pages.- Returns:
- Returns total count of document pages.
-
setUserPassword
Sets user password.- Parameters:
password- Password string.- Returns:
- Returns whether to successfully set user password.
-
setOwnerPassword
Not in use currently -
checkOwnerPassword
-
importAnnotations
Import annotations from XFDF document.- Parameters:
importFilePath- Path of XFDF.tmpCachePath- Cache path.- Returns:
- Returns whether to successfully import annotations from XFDF document.
-
importAnnotations
Import annotations from XFDF document.- Parameters:
importXPDFPath- Path of XFDF.- Returns:
- Returns whether to successfully import annotations from XFDF document.
-
exportAnnotations
Exports annotations to XFDF document.- Parameters:
exportXPDFPath- XFDF path.tmpCacheDirPath- Cache dir path.- Returns:
- Returns whether to successfully export annotations to XFDF document.
-
getPageSize
Gets page size at the specified index.- Parameters:
pageNum- Page index.- Returns:
- Returns page size at the specified index.
-
getPageLabel
Gets the page label at the specified index.- Parameters:
pageNum- Page index.- Returns:
- Returns the page label at the specified index.
-
pageAtIndex
Returns a pageNum object representing the page at index, more:CPDFPage.- Parameters:
pageNum- Page index.- Returns:
- Returns a pageNum object representing the page at index.
-
copyPage
Copy the page at page index- Parameters:
pageNum- Page Index- Returns:
- Returns a page object at index
-
addPage
Add page to document- Parameters:
page- Page object to add to document.pageNum- Position to add to.- Returns:
- Returns whether add is suceess.
-
insertBlankPage
Inserts a blank page at the specified index point.- Parameters:
pageIndex- Page index.width- Page width.height- Page height.- Returns:
- Returns the inserted blank page.
-
insertPageWithImagePath
public CPDFPage insertPageWithImagePath(int pageNum, float width, float height, String imagePath, CPDFDocument.PDFDocumentImageMode imageMode) Inserts a blank page with image at the specified index point.- Parameters:
pageNum- Page.width- Page width.height- Page height.imagePath- File path of image resource.imageMode- Fill mode.- Returns:
- Returns the inserted image page.
-
importPages
Import page(s) from another document at the specified index point and insert toinsertPosition.- Parameters:
otherDocument- Other document.start- Start page index.end- End page index.insertPosition- Insert position.- Returns:
- Returns whether to successfully import page(s).
-
importPages
Import page(s) from another document at the specified index point and insert toinsertPosition.- Parameters:
otherDocument- Other document.pages- Page index array.insertPosition- Insert position.- Returns:
- Returns whether to successfully import page(s).
-
removePages
public boolean removePages(int[] pageNums) Remove page(s).- Parameters:
pageNums- Page index array.- Returns:
- Returns whether to successfully remove page(s).
-
movePage
public boolean movePage(int fromIndex, int toIndex) Moves page.- Parameters:
fromIndex- Source page index.toIndex- Destination page index.- Returns:
- Returns whether to successfully move page.
-
exchangePage
public boolean exchangePage(int firstIndex, int secondIndex) Exchanges one page with another.- Parameters:
firstIndex- The first page index.secondIndex- The second page index.- Returns:
- Returns whether to successfully exchange page.
-
indexOfPage
Gets the index number for the specified page.- Parameters:
page- Page object.- Returns:
- Returns the index number for the specified page.
-
releaseAllPages
public void releaseAllPages()When CPDFPage is no longer in use, release all resource of CPDFPage. -
releaseAllWatermarks
public void releaseAllWatermarks() -
close
public void close()When the object is no longer in use, call this method to release resources. -
hasChanges
public boolean hasChanges()Whether document is modified.- Returns:
- Returns whether document is modified.
-
canSaveIncrementally
public boolean canSaveIncrementally()Whether document can be saved incrementally.- Returns:
- Returns whether document can be saved incrementally.
-
hasRepaired
public boolean hasRepaired()Whether document is repaired.- Returns:
- Returns whether document is repaired.
-
flattenAllPages
Flatten all pages.- Parameters:
flattenOption- flatten type, more:CPDFPage.PDFFlattenOption- Returns:
- Returns whether to successfully flatten all pages.
-
saveForceByNoincremental
public boolean saveForceByNoincremental()Mandatory saving, the principle is to use non-incremental saving as a document to copy the current document -
save
The doucment has changes, sava file. -
getDocPtr
public long getDocPtr() -
save
The doucment has changes, sava file. -
getFilePath
document absolute path -
getWatermarkCount
public int getWatermarkCount() -
getWatermark
getWatermark- Parameters:
index- index- Returns:
- CPDFWatermark
-
createWatermark
createWatermark- Parameters:
type- CPDFWatermark.Type- Returns:
- CPDFWatermark
-
createCompare
-
createCompare
-
createCompareDrawings
-
removeSignature
Delete signature- Parameters:
signature- CPDFSignaturedocument- CPDFDocumentisRemoveAP- isRemove- Returns:
- boolean
-
removeAllSignStamps
Remove all signatures- Parameters:
document- CPDFDocumentisRemoveAP- isRemove- Returns:
- boolean
-
getSignatureCount
public int getSignatureCount()Get the total number of signatures in the document.- Returns:
- Total number of signatures.
-
getPdfSignature
Get the signature of the specified index in the document.- Parameters:
index- index- Returns:
- CPDFSignature
-
writeSignature
public boolean writeSignature(CPDFSignatureWidget signatureWidget, String savePath, String pkcs12certPath, String password, String location, String reason, CPDFDocument.PDFDocMdpP type) Add a signature to document.- Parameters:
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- Returns:
- Returns true:write signature succeed, false:fail.
-
exportWidgets
以xfdf文件格式导出当前文档的表单数据- Parameters:
exportFilePath- xfdf的路径tmpCachePath- 文件的中转路径,该路径一定要具有权限- Returns:
- 是否成功导出表单数据
-
importWidgets
导入表单数据- Parameters:
importFilePath-cachePath-- Returns:
- 是否成功导入表单数据
-
exportCustomWidgets
以xfdf文件格式导出当前文档的所有自定义表单- Parameters:
exportFilePath- xfdf的路径tmpCachePath- 文件的中转路径,该路径一定要具有权限- Returns:
- 是否成功导出表单
-
importCustomWidgets
通过xfdf文件导入自定义表单到当前文档- Parameters:
importFilePath- xfdf的路径tmpCachePath- 文件的中转路径,该路径一定要具有权限- Returns:
- 是否成功导入表单
-
addTable
-