You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2025/11/17 14:09:48 UTC

svn commit: r1929806 - pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers

Author: tilman
Date: Mon Nov 17 14:09:48 2025
New Revision: 1929806

Log:
PDFBOX-5660: avoid NPE, as suggested by Valery Bokov

Modified:
   pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java

Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java
==============================================================================
--- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java	Mon Nov 17 14:09:43 2025	(r1929805)
+++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java	Mon Nov 17 14:09:48 2025	(r1929806)
@@ -169,7 +169,7 @@ public class PDLineAppearanceHandler ext
                 float contentLength = 0;
                 try
                 {
-                    contentLength = font.getStringWidth(annotation.getContents()) / 1000 * FONT_SIZE;
+                    contentLength = font.getStringWidth(contents) / 1000 * FONT_SIZE;
 
                     //TODO How to decide the size of the font?
                     // 9 seems to be standard, but if the text doesn't fit, a scaling is done
@@ -178,7 +178,7 @@ public class PDLineAppearanceHandler ext
                 catch (IllegalArgumentException ex)
                 {
                     // Adobe Reader displays placeholders instead
-                    LOG.error("line text '" + annotation.getContents() + "' can't be shown", ex);
+                    LOG.error("line text '" + contents + "' can't be shown", ex);
                 }
                 float xOffset = (lineLength - contentLength) / 2;
                 float yOffset;
@@ -230,7 +230,7 @@ public class PDLineAppearanceHandler ext
                     cs.setFont(font, FONT_SIZE);
                     cs.newLineAtOffset(xOffset + captionHorizontalOffset, 
                                        y + yOffset + captionVerticalOffset);
-                    cs.showText(annotation.getContents());
+                    cs.showText(contents);
                     cs.endText();
                 }