Fixed positions
This commit is contained in:
parent
a4f8d2f424
commit
156426c9f4
@ -210,7 +210,7 @@ public class TextPositionSequence implements CharSequence {
|
||||
.getYDirAdj() + 2;
|
||||
}
|
||||
|
||||
return new Rectangle(new Point(posXInit, posYInit), posXEnd - posXInit, posYEnd - posYInit + height, page);
|
||||
return new Rectangle(new Point(posXInit - 0.00001f, posYInit), posXEnd - posXInit + 1, posYEnd - posYInit + height, page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.kie.api.KieServices;
|
||||
@ -40,6 +41,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.configuration.v1.api.model.Colors;
|
||||
import com.iqser.red.service.configuration.v1.api.model.DictionaryResponse;
|
||||
import com.iqser.red.service.configuration.v1.api.model.RulesResponse;
|
||||
@ -342,13 +344,44 @@ public class RedactionIntegrationTest {
|
||||
System.out.println("numberOfPages: " + result.getNumberOfPages());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testManualRedaction() throws IOException {
|
||||
|
||||
|
||||
// {
|
||||
// "id": "fed70e44fafdfd814d8caf4738296aa7",
|
||||
// "user": "9f649779-1b43-4ce1-926a-deadeecbdd94",
|
||||
// "type": "manual",
|
||||
// "value": "Shults",
|
||||
// "reason": "the method of manufacture",
|
||||
// "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2a)",
|
||||
// "positions": [
|
||||
// {
|
||||
// "topLeft": {
|
||||
// "x": 167.04001,
|
||||
// "y": 449.00894
|
||||
// },
|
||||
// "width": 30.494343,
|
||||
// "height": 11.852395,
|
||||
// "page": 28
|
||||
// }
|
||||
// ],
|
||||
// "status": "APPROVED",
|
||||
// "addToDictionary": false,
|
||||
// "requestDate": "2020-11-17T10:01:21Z",
|
||||
// "processedDate": "2020-11-17T10:01:21Z"
|
||||
// },
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("testManualRedaction");
|
||||
long start = System.currentTimeMillis();
|
||||
ClassPathResource pdfFileResource = new ClassPathResource("files/Minimal Examples/Single Table.pdf");
|
||||
ClassPathResource pdfFileResource = new ClassPathResource("files/S28.pdf");
|
||||
|
||||
ManualRedactions manualRedactions = new ManualRedactions();
|
||||
|
||||
@ -376,7 +409,7 @@ public class RedactionIntegrationTest {
|
||||
manualRedactionEntry.setReason("Manual Redaction");
|
||||
manualRedactionEntry.setPositions(List.of(new Rectangle(new Point(375.61096f, 241.282f), 7.648041f, 43.72262f, 1), new Rectangle(new Point(384.83517f, 241.282f), 7.648041f, 17.043358f, 1)));
|
||||
|
||||
manualRedactions.getEntriesToAdd().add(manualRedactionEntry);
|
||||
// manualRedactions.getEntriesToAdd().add(manualRedactionEntry);
|
||||
|
||||
RedactionRequest request = RedactionRequest.builder()
|
||||
.document(IOUtils.toByteArray(pdfFileResource.getInputStream()))
|
||||
@ -388,6 +421,11 @@ public class RedactionIntegrationTest {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/Redacted.pdf")) {
|
||||
fileOutputStream.write(result.getDocument());
|
||||
}
|
||||
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/log.txt")) {
|
||||
fileOutputStream.write(objectMapper.writeValueAsBytes(result.getRedactionLog()));
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
System.out.println("duration: " + (end - start));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user