From ba55c48fd6cb5fe52aee8ca8cec62bb3e00c2698 Mon Sep 17 00:00:00 2001 From: "valery.bokov" Date: Sun, 21 Sep 2025 10:09:38 +0200 Subject: [PATCH] improve performance for AnnotationBorder.getAnnotationBuilder --- .../annotation/handlers/AnnotationBorder.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java index 5e4e9c0909a..21d1c67b331 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java @@ -42,9 +42,13 @@ static AnnotationBorder getAnnotationBorder(PDAnnotation annotation, if (borderStyle == null) { COSArray border = annotation.getBorder(); - if (border.size() >= 3 && border.getObject(2) instanceof COSNumber) + if (border.size() >= 3) { - ab.width = ((COSNumber) border.getObject(2)).floatValue(); + COSBase base = border.getObject(2); + if (base instanceof COSNumber) + { + ab.width = ((COSNumber) base).floatValue(); + } } if (border.size() > 3) { @@ -58,11 +62,12 @@ static AnnotationBorder getAnnotationBorder(PDAnnotation annotation, else { ab.width = borderStyle.getWidth(); - if (borderStyle.getStyle().equals(PDBorderStyleDictionary.STYLE_DASHED)) + String style = borderStyle.getStyle(); + if (style.equals(PDBorderStyleDictionary.STYLE_DASHED)) { ab.dashArray = borderStyle.getDashStyle().getDashArray(); } - if (borderStyle.getStyle().equals(PDBorderStyleDictionary.STYLE_UNDERLINE)) + if (style.equals(PDBorderStyleDictionary.STYLE_UNDERLINE)) { ab.underline = true; }