fix: position of rectangle, add test
This commit is contained in:
parent
d0cbb5293a
commit
3052b82842
@ -216,7 +216,7 @@ public class PdfSegmentationService {
|
|||||||
// set Image, Position and type for merged Image
|
// set Image, Position and type for merged Image
|
||||||
//set position for merged image with values of image1 and the height of both
|
//set position for merged image with values of image1 and the height of both
|
||||||
Rectangle2D pos = new Rectangle2D.Float();
|
Rectangle2D pos = new Rectangle2D.Float();
|
||||||
pos.setRect(image1.getPosition().getX(), image1.getPosition().getY(), width,height1+height2);
|
pos.setRect(image1.getPosition().getX(), image2.getPosition().getY(), width,height1+height2);
|
||||||
newPdfImage = new PdfImage(mergedImage,pos,0);
|
newPdfImage = new PdfImage(mergedImage,pos,0);
|
||||||
// Graphics need to be disposed
|
// Graphics need to be disposed
|
||||||
newPdfImage.getImage().flush();
|
newPdfImage.getImage().flush();
|
||||||
|
|||||||
@ -121,14 +121,6 @@ public class SectionsBuilderService {
|
|||||||
paragraphMap.computeIfAbsent(1, x -> new TreeSet<>()).add(paragraph);
|
paragraphMap.computeIfAbsent(1, x -> new TreeSet<>()).add(paragraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
// first page is always a paragraph, else we can't process pages 1..N,
|
|
||||||
// where N is the first found page with a paragraph
|
|
||||||
if (paragraphMap.get(1) == null) {
|
|
||||||
Paragraph paragraph = new Paragraph();
|
|
||||||
document.getParagraphs().add(paragraph);
|
|
||||||
paragraphMap.computeIfAbsent(1, x -> new TreeSet<>()).add(paragraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Page page : document.getPages()) {
|
for (Page page : document.getPages()) {
|
||||||
for (PdfImage image : page.getImages()) {
|
for (PdfImage image : page.getImages()) {
|
||||||
SortedSet<Paragraph> paragraphsOnPage = paragraphMap.get(page.getPageNumber());
|
SortedSet<Paragraph> paragraphsOnPage = paragraphMap.get(page.getPageNumber());
|
||||||
|
|||||||
@ -74,6 +74,8 @@ public class PdfSegmentationServiceTest {
|
|||||||
ClassPathResource pdfFileResource = new ClassPathResource("files/Minimal Examples/270Rotated.pdf");
|
ClassPathResource pdfFileResource = new ClassPathResource("files/Minimal Examples/270Rotated.pdf");
|
||||||
|
|
||||||
Document document = pdfSegmentationService.parseDocument(pdfFileResource.getInputStream());
|
Document document = pdfSegmentationService.parseDocument(pdfFileResource.getInputStream());
|
||||||
|
assertThat(document.getPages().get(0).getImages().size()).isEqualTo(1);
|
||||||
|
assertThat(document.getPages().get(1).getImages().size()).isEqualTo(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user