From d405b7a810dcf973ddbce5819d2e239b9105b152 Mon Sep 17 00:00:00 2001 From: sbplat <71648843+sbplat@users.noreply.github.com> Date: Wed, 27 Dec 2023 22:46:55 -0500 Subject: [PATCH] perf: avoid re-rendering the first pdf page --- src/main/java/stirling/software/SPDF/utils/PdfUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java index 7ae91cf9..2be68d08 100644 --- a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java @@ -236,7 +236,9 @@ public class PdfUtils { Graphics g = combined.getGraphics(); for (int i = 0; i < pageCount; ++i) { - BufferedImage image = pdfRenderer.renderImageWithDPI(i, DPI, colorType); + if (i != 0) { + image = pdfRenderer.renderImageWithDPI(i, DPI, colorType); + } g.drawImage(image, 0, i * image.getHeight(), null); }