From 12d86049f6cd030ac8ff9f0e4df2564f17546e08 Mon Sep 17 00:00:00 2001 From: Reece Browne Date: Wed, 18 Dec 2024 00:30:06 +0000 Subject: [PATCH] Add default to convert image to pdf api --- .../api/converters/ConvertImgPDFController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index b5eec392..3e4fa6ba 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -210,7 +210,13 @@ public class ConvertImgPDFController { String fitOption = request.getFitOption(); String colorType = request.getColorType(); boolean autoRotate = request.isAutoRotate(); - + // Handle Null entries for formdata + if (colorType == null || colorType.isBlank()) { + colorType = "color"; + } + if (fitOption == null || fitOption.isEmpty()) { + fitOption = "fitDocumentToImage"; + } // Convert the file to PDF and get the resulting bytes byte[] bytes = PdfUtils.imageToPdf(file, fitOption, autoRotate, colorType, pdfDocumentFactory);