mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Update pdfbox to 3.0.0
This commit is contained in:
@ -16,6 +16,7 @@ import docspell.logging.Logger
|
||||
|
||||
import org.apache.pdfbox.pdmodel.PDDocument
|
||||
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException
|
||||
import org.apache.pdfbox.{Loader => PdfboxLoader}
|
||||
|
||||
/** Using PDFBox, the incoming pdf is loaded while trying the given passwords. */
|
||||
object RemovePdfEncryption {
|
||||
@ -76,7 +77,7 @@ object RemovePdfEncryption {
|
||||
}
|
||||
|
||||
private def load(bytes: Array[Byte], pw: Password): Option[PDDocument] =
|
||||
try Option(PDDocument.load(bytes, pw.pass))
|
||||
try Option(PdfboxLoader.loadPDF(bytes, pw.pass))
|
||||
catch {
|
||||
case _: InvalidPasswordException =>
|
||||
None
|
||||
|
@ -22,8 +22,8 @@ import docspell.common.util.File
|
||||
import docspell.convert.ConversionResult.Handler
|
||||
import docspell.files.TikaMimetype
|
||||
|
||||
import org.apache.pdfbox.pdmodel.PDDocument
|
||||
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException
|
||||
import org.apache.pdfbox.{Loader => PdfboxLoader}
|
||||
|
||||
trait FileChecks {
|
||||
|
||||
@ -42,7 +42,7 @@ trait FileChecks {
|
||||
isType(MimeType.text("plain"))
|
||||
|
||||
def isUnencryptedPDF: Boolean =
|
||||
Try(PDDocument.load(p.toNioPath.toFile)).map(_.close()).isSuccess
|
||||
Try(PdfboxLoader.loadPDF(p.toNioPath.toFile)).map(_.close()).isSuccess
|
||||
}
|
||||
|
||||
implicit class ByteStreamOps(delegate: Stream[IO, Byte]) {
|
||||
@ -58,14 +58,14 @@ trait FileChecks {
|
||||
def isUnencryptedPDF: IO[Boolean] =
|
||||
delegate.compile
|
||||
.to(Array)
|
||||
.map(PDDocument.load(_))
|
||||
.map(PdfboxLoader.loadPDF)
|
||||
.map(_.close())
|
||||
.map(_ => true)
|
||||
|
||||
def isEncryptedPDF: IO[Boolean] =
|
||||
delegate.compile
|
||||
.to(Array)
|
||||
.map(PDDocument.load(_))
|
||||
.map(PdfboxLoader.loadPDF)
|
||||
.attempt
|
||||
.map(e =>
|
||||
e.fold(
|
||||
|
Reference in New Issue
Block a user