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 2017/02/08 16:32:35 UTC
svn commit: r1782214 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Author: tilman
Date: Wed Feb 8 16:32:35 2017
New Revision: 1782214
URL: http://svn.apache.org/viewvc?rev=1782214&view=rev
Log:
PDFBOX-3660: fill missing elements of existing array with 0 to behave like Adobe Reader
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java?rev=1782214&r1=1782213&r2=1782214&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java Wed Feb 8 16:32:35 2017
@@ -627,8 +627,11 @@ public abstract class PDAnnotation imple
}
/**
- * This will retrieve the border array. If none is available or if it doesn't have at least
- * three elements, it will return the default, which is [0 0 1].
+ * This will retrieve the border array. If none is available then it will return the default,
+ * which is [0 0 1]. The array consists of at least three numbers defining the horizontal corner
+ * radius, vertical corner radius, and border width. The array may have a fourth element, an
+ * optional dash array defining a pattern of dashes and gaps that shall be used in drawing the
+ * border. If the array has less than three elements, it will be filled with 0.
*
* @return the border array.
*/
@@ -636,17 +639,29 @@ public abstract class PDAnnotation imple
{
COSBase base = getCOSObject().getDictionaryObject(COSName.BORDER);
COSArray border;
- if (!(base instanceof COSArray) || ((COSArray) base).size() < 3)
+ if (base instanceof COSArray)
+ {
+ border = (COSArray) base;
+ if (border.size() < 3)
+ {
+ // create a copy to avoid altering the PDF
+ COSArray newBorder = new COSArray();
+ newBorder.addAll(border);
+ border = newBorder;
+ // Adobe Reader behaves as if missing elements are 0.
+ while (border.size() < 3)
+ {
+ border.add(COSInteger.ZERO);
+ }
+ }
+ }
+ else
{
border = new COSArray();
border.add(COSInteger.ZERO);
border.add(COSInteger.ZERO);
border.add(COSInteger.ONE);
}
- else
- {
- border = (COSArray) base;
- }
return border;
}