ATS-996: TIFF to PDF - invalid output format

This commit is contained in:
Krystian Dabrowski
2023-03-27 16:39:35 +02:00
parent b84a5613f3
commit 8c59a96470
2 changed files with 8 additions and 5 deletions

View File

@@ -64,6 +64,7 @@ public class AIOTikaTest extends TikaTest
"page", "page",
"pageLimit", "pageLimit",
"pdfFormat", "pdfFormat",
"pdfOrientation",
"resizeHeight", "resizeHeight",
"resizePercentage", "resizePercentage",
"resizeWidth", "resizeWidth",

View File

@@ -150,12 +150,13 @@ public class ImageToPdfTransformer implements CustomTransformerFileAdaptor
} }
} }
private PDRectangle resolvePdfFormat(final String pdfFormat, final String pdfOrientation, final int actualWidth, final int actualHeight) private PDRectangle resolvePdfFormat(final String pdfFormat, final String pdfOrientation, final int defaultWidth, final int defaultHeight)
{ {
PDRectangle pdRectangle; PDRectangle pdRectangle;
switch (pdfFormat.toUpperCase()) { switch (pdfFormat.toUpperCase())
{
case "DEFAULT": case "DEFAULT":
pdRectangle = new PDRectangle(actualWidth, actualHeight); pdRectangle = new PDRectangle(defaultWidth, defaultHeight);
break; break;
case "A4": case "A4":
pdRectangle = PDRectangle.A4; pdRectangle = PDRectangle.A4;
@@ -186,11 +187,12 @@ public class ImageToPdfTransformer implements CustomTransformerFileAdaptor
break; break;
default: default:
log.warn("PDF format: '{}' not supported. Maintaining the default one.", pdfFormat); log.warn("PDF format: '{}' not supported. Maintaining the default one.", pdfFormat);
pdRectangle = new PDRectangle(actualWidth, actualHeight); pdRectangle = new PDRectangle(defaultWidth, defaultHeight);
break; break;
} }
switch (pdfOrientation.toUpperCase()) { switch (pdfOrientation.toUpperCase())
{
case "DEFAULT": case "DEFAULT":
break; break;
case "PORTRAIT": case "PORTRAIT":