diff --git a/src/main/java/stirling/software/SPDF/controller/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/converters/ConvertImgPDFController.java index 6e1c624a..25b58297 100644 --- a/src/main/java/stirling/software/SPDF/controller/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/converters/ConvertImgPDFController.java @@ -61,7 +61,7 @@ public class ConvertImgPDFController { boolean singleImage = singleOrMultiple.equals("single"); byte[] result = null; try { - result = PdfUtils.convertFromPdf(pdfBytes, imageFormat.toLowerCase(), colorTypeResult, singleImage, Integer.valueOf(dpi)); + result = PdfUtils.convertFromPdf(pdfBytes, imageFormat.toUpperCase(), colorTypeResult, singleImage, Integer.valueOf(dpi)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java index 76c56cc3..67629c0c 100644 --- a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java @@ -107,7 +107,7 @@ public class PdfUtils { ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (singleImage) { // Write the image to the output stream - ImageIO.write(images.get(0), "PNG", baos); + ImageIO.write(images.get(0), imageType, baos); // Log that the image was successfully written to the byte array logger.info("Image successfully written to byte array"); @@ -117,10 +117,10 @@ public class PdfUtils { for (int i = 0; i < images.size(); i++) { BufferedImage image = images.get(i); try (ByteArrayOutputStream baosImage = new ByteArrayOutputStream()) { - ImageIO.write(image, "PNG", baosImage); + ImageIO.write(image, imageType, baosImage); // Add the image to the zip file - zos.putNextEntry(new ZipEntry(String.format("page_%d.%s", i + 1, "png"))); + zos.putNextEntry(new ZipEntry(String.format("page_%d.%s", i + 1, imageType.toLowerCase()))); zos.write(baosImage.toByteArray()); } } diff --git a/src/main/resources/templates/convert/pdf-to-img.html b/src/main/resources/templates/convert/pdf-to-img.html index ef6c48ee..29307d5d 100644 --- a/src/main/resources/templates/convert/pdf-to-img.html +++ b/src/main/resources/templates/convert/pdf-to-img.html @@ -21,6 +21,8 @@