RED-9746: use quadtree for visible and overlapped elements
This commit is contained in:
parent
d5c506d080
commit
f4538648ff
@ -158,7 +158,6 @@ public class InvisibleElementRemovalService {
|
||||
int pageIndex = 1;
|
||||
|
||||
for (PageIterator iterator = pdfDoc.getPageIterator(); iterator.hasNext(); ) {
|
||||
|
||||
Page page = iterator.next();
|
||||
|
||||
visitedXObjIds.add(page.getSDFObj().getObjNum());
|
||||
@ -183,8 +182,8 @@ public class InvisibleElementRemovalService {
|
||||
removeOverlappedElements(page, writer, context);
|
||||
pageIndex++;
|
||||
}
|
||||
log.info("Finished removing invisible Elements");
|
||||
}
|
||||
log.info("Finished removing invisible Elements");
|
||||
}
|
||||
|
||||
|
||||
@ -254,7 +253,7 @@ public class InvisibleElementRemovalService {
|
||||
if (inClippingPath) {
|
||||
ImageFeatures image = ElementFeatureFactory.buildImage(imageElement);
|
||||
if (nonTransparent) {
|
||||
calculateOverlaps(context, image, writer);
|
||||
// calculateOverlaps(context, image, writer);
|
||||
}
|
||||
context.visibleElements().add(image);
|
||||
}
|
||||
@ -479,7 +478,7 @@ public class InvisibleElementRemovalService {
|
||||
Therefore, the position of a following Tj is affected by not writing the first Element.
|
||||
This is why, we write only the Tm command:
|
||||
*/
|
||||
writer.writeGStateChanges(element);
|
||||
writer.writeGStateChanges(element);
|
||||
} else {
|
||||
writer.writeElement(element);
|
||||
}
|
||||
|
||||
@ -3,12 +3,10 @@ package com.iqser.red.pdftronlogic.commons;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -53,7 +51,20 @@ public class VisualEqualityTest {
|
||||
@SneakyThrows
|
||||
public void assertVisualEqualityOfProcessedFile() {
|
||||
|
||||
Path folder = Path.of("/home/kschuettler/Dokumente/TestFiles/syn-dm-testfiles/ITEM 19_A15149AC - Primary Skin Irritation Rabbit.pdf");
|
||||
Path file = Path.of("/home/kschuettler/Dokumente/TestFiles/syn-dm-testfiles/ITEM 23_A19022A - Dermal Absorption Human.pdf");
|
||||
Context context = new Context(stem, new HashMap<>());
|
||||
|
||||
runForFile(file, context);
|
||||
|
||||
|
||||
assert context.failedFiles.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void assertVisualEqualityOfProcessedFolder() {
|
||||
|
||||
Path folder = Path.of("/home/kschuettler/Dokumente/TestFiles/syn-dm-testfiles");
|
||||
Context context = new Context(stem, new HashMap<>());
|
||||
|
||||
Files.walk(folder)
|
||||
@ -86,8 +97,9 @@ public class VisualEqualityTest {
|
||||
try (var in = new FileInputStream(copiedOriginFile.toFile()); var out = new FileOutputStream(deltaFile.toFile())) {
|
||||
invisibleElementRemovalService.removeInvisibleElements(in, out, true);
|
||||
}
|
||||
|
||||
System.out.println("removed invisible elements");
|
||||
assertVisualEquality(originFile, processedFile, context);
|
||||
System.out.println("finished visual equality check");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user