Fixed multiline annotations
This commit is contained in:
parent
ecdfd29803
commit
247e57208a
@ -227,7 +227,7 @@ public class AnnotationHighlightService {
|
|||||||
|
|
||||||
PDAnnotationTextMarkup annotation = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
|
PDAnnotationTextMarkup annotation = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
|
||||||
annotation.constructAppearances();
|
annotation.constructAppearances();
|
||||||
annotation.setRectangle(toPDRectangle(rectangles.get(0)));
|
annotation.setRectangle(toPDRectangle(rectangles));
|
||||||
annotation.setQuadPoints(toQuadPoints(rectangles));
|
annotation.setQuadPoints(toQuadPoints(rectangles));
|
||||||
if (popup) {
|
if (popup) {
|
||||||
annotation.setAnnotationName(id);
|
annotation.setAnnotationName(id);
|
||||||
@ -252,13 +252,34 @@ public class AnnotationHighlightService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private PDRectangle toPDRectangle(Rectangle rectangle) {
|
private PDRectangle toPDRectangle(List<Rectangle> rectangles) {
|
||||||
|
|
||||||
|
|
||||||
|
float x1 = Float.MAX_VALUE;
|
||||||
|
float x2 = 0;
|
||||||
|
float y1 = 0;
|
||||||
|
float y2 = Float.MAX_VALUE;
|
||||||
|
|
||||||
|
for(Rectangle rectangle : rectangles){
|
||||||
|
if (rectangle.getTopLeft().getX() < x1){
|
||||||
|
x1 = rectangle.getTopLeft().getX();
|
||||||
|
}
|
||||||
|
if(rectangle.getTopLeft().getX() + rectangle.getWidth() > x2){
|
||||||
|
x2 = rectangle.getTopLeft().getX() + rectangle.getWidth();
|
||||||
|
}
|
||||||
|
if(rectangle.getTopLeft().getY() + rectangle.getHeight() > y1){
|
||||||
|
y1 = rectangle.getTopLeft().getY() + rectangle.getHeight();
|
||||||
|
}
|
||||||
|
if(rectangle.getTopLeft().getY() < y2){
|
||||||
|
y2 = rectangle.getTopLeft().getY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PDRectangle annotationPosition = new PDRectangle();
|
PDRectangle annotationPosition = new PDRectangle();
|
||||||
annotationPosition.setLowerLeftX(rectangle.getTopLeft().getX());
|
annotationPosition.setLowerLeftX(x1);
|
||||||
annotationPosition.setLowerLeftY(rectangle.getTopLeft().getY() + rectangle.getHeight());
|
annotationPosition.setLowerLeftY(y1);
|
||||||
annotationPosition.setUpperRightX(rectangle.getTopLeft().getX() + rectangle.getWidth());
|
annotationPosition.setUpperRightX(x2);
|
||||||
annotationPosition.setUpperRightY(rectangle.getTopLeft().getY());
|
annotationPosition.setUpperRightY(y2);
|
||||||
return annotationPosition;
|
return annotationPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user