Skip to content

Commit

Permalink
deps(komga): bump org.apache.pdfbox:pdfbox from 2.0.28 to 3.0.1
Browse files Browse the repository at this point in the history
Closes: #1334
  • Loading branch information
gotson committed Jan 22, 2024
1 parent 295bfaf commit 38fcde9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion komga/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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 ->
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions komga/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 38fcde9

Please sign in to comment.