deps(komga): bump org.apache.pdfbox:pdfbox from 2.0.28 to 3.0.1

Closes: #1334
This commit is contained in:
Gauthier Roebroeck 2024-01-22 10:50:19 +08:00
parent 295bfaf695
commit 38fcde9ee7
3 changed files with 6 additions and 6 deletions

View File

@ -90,7 +90,7 @@ dependencies {
implementation("org.apache.commons:commons-compress:1.24.0")
implementation("com.github.junrar:junrar:7.5.5")
implementation("com.github.gotson.nightcompress:nightcompress:0.2.0")
implementation("org.apache.pdfbox:pdfbox:2.0.28")
implementation("org.apache.pdfbox:pdfbox:3.0.1")
implementation("net.grey-panther:natural-comparator:1.1")
implementation("org.jsoup:jsoup:1.16.2")

View File

@ -1,9 +1,8 @@
package org.gotson.komga.infrastructure.mediacontainer.pdf
import io.github.oshai.kotlinlogging.KotlinLogging
import org.apache.pdfbox.io.MemoryUsageSetting
import org.apache.pdfbox.Loader
import org.apache.pdfbox.multipdf.PageExtractor
import org.apache.pdfbox.pdmodel.PDDocument
import org.apache.pdfbox.pdmodel.PDPage
import org.apache.pdfbox.rendering.ImageType.RGB
import org.apache.pdfbox.rendering.PDFRenderer
@ -29,7 +28,7 @@ class PdfExtractor(
private val resolution: Float,
) {
fun getPages(path: Path, analyzeDimensions: Boolean): List<MediaContainerEntry> =
PDDocument.load(path.toFile(), MemoryUsageSetting.setupTempFileOnly()).use { pdf ->
Loader.loadPDF(path.toFile()).use { pdf ->
(0 until pdf.numberOfPages).map { index ->
val page = pdf.getPage(index)
val dimension = if (analyzeDimensions) Dimension(page.cropBox.width.roundToInt(), page.cropBox.height.roundToInt()) else null
@ -38,7 +37,7 @@ class PdfExtractor(
}
fun getPageContentAsImage(path: Path, pageNumber: Int): TypedBytes {
PDDocument.load(path.toFile(), MemoryUsageSetting.setupTempFileOnly()).use { pdf ->
Loader.loadPDF(path.toFile()).use { pdf ->
val page = pdf.getPage(pageNumber - 1)
val image = PDFRenderer(pdf).renderImage(pageNumber - 1, page.getScale(), RGB)
val bytes = ByteArrayOutputStream().use { out ->
@ -50,7 +49,7 @@ class PdfExtractor(
}
fun getPageContentAsPdf(path: Path, pageNumber: Int): TypedBytes {
PDDocument.load(path.toFile(), MemoryUsageSetting.setupTempFileOnly()).use { pdf ->
Loader.loadPDF(path.toFile()).use { pdf ->
val bytes = ByteArrayOutputStream().use { out ->
PageExtractor(pdf, pageNumber, pageNumber).extract().save(out)
out.toByteArray()

View File

@ -11,6 +11,7 @@ logging:
name: \${komga.config-dir}/logs/komga.log
level:
org.apache.activemq.audit: WARN
org.apache.fontbox.cff.Type1CharString: ERROR
komga:
database: