Skip to content

Commit

Permalink
fix(api): cannot get last page of PDF
Browse files Browse the repository at this point in the history
Closes: #1341
  • Loading branch information
gotson committed Dec 12, 2023
1 parent b312847 commit 721c5d1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PdfExtractor(

fun getPageContentAsImage(path: Path, pageNumber: Int): TypedBytes {
PDDocument.load(path.toFile(), MemoryUsageSetting.setupTempFileOnly()).use { pdf ->
val page = pdf.getPage(pageNumber)
val page = pdf.getPage(pageNumber - 1)
val image = PDFRenderer(pdf).renderImage(pageNumber - 1, page.getScale(), RGB)
val bytes = ByteArrayOutputStream().use { out ->
ImageIO.write(image, imageType.imageIOFormat, out)
Expand Down

0 comments on commit 721c5d1

Please sign in to comment.