Commit 010ca428 authored by wanglei's avatar wanglei

...

parent 32090825
...@@ -94,8 +94,11 @@ object PdfBoxUtils { ...@@ -94,8 +94,11 @@ object PdfBoxUtils {
ownerPassword: String ownerPassword: String
): Boolean { ): Boolean {
var pdDocument: PDDocument? = null
try { try {
PDDocument.load(File(sourceFilePath)).use { document ->
pdDocument = PDDocument.load(File(sourceFilePath))
pdDocument.use { document ->
val ap = AccessPermission() val ap = AccessPermission()
ap.setCanPrint(false) ap.setCanPrint(false)
ap.setCanModify(false) ap.setCanModify(false)
...@@ -111,6 +114,8 @@ object PdfBoxUtils { ...@@ -111,6 +114,8 @@ object PdfBoxUtils {
LogEx.logDebug(TAG, "setPassword Exception ${e.printStackTrace()}") LogEx.logDebug(TAG, "setPassword Exception ${e.printStackTrace()}")
e.printStackTrace() e.printStackTrace()
return false return false
} finally {
pdDocument?.close()
} }
return true return true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment