RED-7075: WatermarkRemoval improved
This commit is contained in:
parent
5e4edbec66
commit
b99f9f26fe
@ -39,21 +39,20 @@ public class WatermarkRemovalService {
|
|||||||
PDFDoc pdfDoc = new PDFDoc(pdfFile);
|
PDFDoc pdfDoc = new PDFDoc(pdfFile);
|
||||||
|
|
||||||
if(pdfDoc.getPageCount() < MIN_PAGES_THRESHOLD){
|
if(pdfDoc.getPageCount() < MIN_PAGES_THRESHOLD){
|
||||||
log.debug("Document page count {} is below threshold {}", pdfDoc.getPageCount(), MIN_PAGES_THRESHOLD);
|
log.info("Document page count {} is below threshold {}", pdfDoc.getPageCount(), MIN_PAGES_THRESHOLD);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Long, List<ElementFeatures>> formObjectsForPages = findAllFormObjectsAndImages(pdfDoc);
|
|
||||||
|
|
||||||
List<ElementFeatures> watermarkElementFeatures = filterSameFormObjectsOccuringOnMostPages(formObjectsForPages);
|
|
||||||
|
|
||||||
if(watermarkElementFeatures.size() > 0){
|
|
||||||
log.info("Watermark found and will be removed!");
|
|
||||||
} else {
|
} else {
|
||||||
log.info("No watermark found!");
|
Map<Long, List<ElementFeatures>> formObjectsForPages = findAllFormObjectsAndImages(pdfDoc);
|
||||||
}
|
|
||||||
|
|
||||||
removeAllWatermarks(pdfDoc, watermarkElementFeatures);
|
List<ElementFeatures> 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 {
|
try {
|
||||||
pdfDoc.save(out, SDFDoc.SaveMode.LINEARIZED, null);
|
pdfDoc.save(out, SDFDoc.SaveMode.LINEARIZED, null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user