RED-4114: Fixed text rotation for rotation = 0 and text direction = 180

This commit is contained in:
deiflaender 2022-06-09 09:23:17 +02:00
parent 6fec4cc209
commit df4bd056cc
4 changed files with 36 additions and 1 deletions

View File

@ -261,7 +261,7 @@ public class TextPositionSequence implements CharSequence {
@JsonAttribute(ignore = true) @JsonAttribute(ignore = true)
public Rectangle getRectangle() { public Rectangle getRectangle() {
log.debug("Page: '{}', Word: '{}', Rotation: '{}', textRotation {}", page, toString(), textPositions.get(0).getRotation(), textPositions.get(0).getDir()); log.info("Page: '{}', Word: '{}', Rotation: '{}', textRotation {}", page, toString(), textPositions.get(0).getRotation(), textPositions.get(0).getDir());
float height = getTextHeight(); float height = getTextHeight();
@ -320,6 +320,14 @@ public class TextPositionSequence implements CharSequence {
posYEnd = textPositions.get(textPositions.size() - 1) posYEnd = textPositions.get(textPositions.size() - 1)
.getYDirAdj() - height + 2; .getYDirAdj() - height + 2;
} else if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 180f) {
posXInit = textPositions.get(0).getPageWidth() - getX1() + 1;
posXEnd = textPositions.get(0).getPageWidth() - getX2() + textPositions.get(0).getWidthDirAdj() - textPositions.get(textPositions.size() - 1)
.getWidthDirAdj() - 3;
posYInit = textPositions.get(0).getYDirAdj() - height + 2;
posYEnd = textPositions.get(textPositions.size() - 1)
.getYDirAdj() - height + 2;
} else { } else {
posXEnd = textPositions.get(textPositions.size() - 1) posXEnd = textPositions.get(textPositions.size() - 1)
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 1; .getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 1;

View File

@ -807,6 +807,31 @@ public class RedactionIntegrationTest {
} }
@Test
public void testRotations() throws IOException {
System.out.println("testTableRedaction");
long start = System.currentTimeMillis();
AnalyzeRequest request = prepareStorage("files/new/RotateTestfile.pdf");
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(request.getDossierId(), request.getFileId()));
AnalyzeResult result = analyzeService.analyze(request);
AnnotateResponse annotateResponse = annotationService.annotate(AnnotateRequest.builder()
.dossierId(TEST_DOSSIER_ID)
.fileId(TEST_FILE_ID)
.build());
try (FileOutputStream fileOutputStream = new FileOutputStream(OsUtils.getTemporaryDirectory() + "/Annotated.pdf")) {
fileOutputStream.write(annotateResponse.getDocument());
}
long end = System.currentTimeMillis();
System.out.println("duration: " + (end - start));
System.out.println("numberOfPages: " + result.getNumberOfPages());
}
@Test @Test
public void testFindDictionaryEntryInResizedEntryPosition() throws IOException { public void testFindDictionaryEntryInResizedEntryPosition() throws IOException {

View File

@ -11,3 +11,5 @@ Sude Halide Nurullah
Xinyi Y. Tao Xinyi Y. Tao
Dorn Dorn
Prasher Prasher
RuleAnnotation270GradP
RuleAnnotation270GradLS