Commit 82754571 authored by wanglei's avatar wanglei

...

parent 7498a828
...@@ -54,9 +54,9 @@ object PdfBoxUtils { ...@@ -54,9 +54,9 @@ object PdfBoxUtils {
fun checkPdfEncryption(filePath: String = "", uri: String? = null): Int { fun checkPdfEncryption(filePath: String = "", uri: String? = null): Int {
var state = 0 var state = 0
var pdfDocument: PDDocument? = null
try { try {
val pdfDocument = loadPDDocument(filePath, null, uri) pdfDocument = loadPDDocument(filePath, null, uri)
pdfDocument.use { document -> pdfDocument.use { document ->
if (document.isEncrypted) { if (document.isEncrypted) {
println("The PDF is encrypted.") println("The PDF is encrypted.")
...@@ -81,6 +81,8 @@ object PdfBoxUtils { ...@@ -81,6 +81,8 @@ object PdfBoxUtils {
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
state = 1 state = 1
} finally {
pdfDocument?.close()
} }
return state return state
} }
......
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