From 7a9c00e6cf4f9de72109bbbc4513029b2bd5ae46 Mon Sep 17 00:00:00 2001 From: RaphaelArnold Date: Wed, 2 Aug 2023 10:27:31 +0200 Subject: [PATCH] RED-7075: Watermark Removal PMD errors fixed and logs --- .../com/iqser/red/pdftronlogic/commons/ElementFeatures.java | 4 ++-- .../iqser/red/pdftronlogic/commons/ImageHashFactory.java | 2 +- .../red/pdftronlogic/commons/WatermarkRemovalService.java | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iqser/red/pdftronlogic/commons/ElementFeatures.java b/src/main/java/com/iqser/red/pdftronlogic/commons/ElementFeatures.java index 2107928..6681ac9 100644 --- a/src/main/java/com/iqser/red/pdftronlogic/commons/ElementFeatures.java +++ b/src/main/java/com/iqser/red/pdftronlogic/commons/ElementFeatures.java @@ -179,8 +179,8 @@ public class ElementFeatures { int distance = 0; int maxLength = Math.max(this.hashOfImage.length(), hash2.length()); for (int i = 0; i < maxLength; i++) { - char char1 = (i < this.hashOfImage.length()) ? this.hashOfImage.charAt(i) : '0'; - char char2 = (i < hash2.length()) ? hash2.charAt(i) : '0'; + char char1 = i < this.hashOfImage.length() ? this.hashOfImage.charAt(i) : '0'; + char char2 = i < hash2.length() ? hash2.charAt(i) : '0'; if (char1 != char2) { distance++; } diff --git a/src/main/java/com/iqser/red/pdftronlogic/commons/ImageHashFactory.java b/src/main/java/com/iqser/red/pdftronlogic/commons/ImageHashFactory.java index 9e8f701..14fb7f8 100644 --- a/src/main/java/com/iqser/red/pdftronlogic/commons/ImageHashFactory.java +++ b/src/main/java/com/iqser/red/pdftronlogic/commons/ImageHashFactory.java @@ -97,7 +97,7 @@ public class ImageHashFactory { int leftPixel = resizedImage.getRGB(x, y); int rightPixel = resizedImage.getRGB(x + 1, y); hash <<= 1; - hash |= (leftPixel < rightPixel) ? 1 : 0; + hash |= leftPixel < rightPixel ? 1 : 0; } } diff --git a/src/main/java/com/iqser/red/pdftronlogic/commons/WatermarkRemovalService.java b/src/main/java/com/iqser/red/pdftronlogic/commons/WatermarkRemovalService.java index 33435fe..f436047 100644 --- a/src/main/java/com/iqser/red/pdftronlogic/commons/WatermarkRemovalService.java +++ b/src/main/java/com/iqser/red/pdftronlogic/commons/WatermarkRemovalService.java @@ -47,6 +47,12 @@ public class WatermarkRemovalService { List watermarkElementFeatures = filterSameFormObjectsOccuringOnMostPages(formObjectsForPages); + if(watermarkElementFeatures.size() > 0){ + log.info("Watermark found and will be removed!"); + } else { + log.info("No watermark found!"); + } + removeAllWatermarks(pdfDoc, watermarkElementFeatures); try {