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 2019/12/15 08:52:39 UTC
svn commit: r1871573 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Author: tilman
Date: Sun Dec 15 08:52:39 2019
New Revision: 1871573
URL: http://svn.apache.org/viewvc?rev=1871573&view=rev
Log:
PDFBOX-4706: add getter/setter for UserUnit
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1871573&r1=1871572&r2=1871573&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Sun Dec 15 08:52:39 2019
@@ -768,4 +768,32 @@ public class PDPage implements COSObject
page.setItem(COSName.VP, array);
}
+ /**
+ * Get the user unit. This is a positive number that shall give the size of default user space
+ * units, in multiples of 1/72 inch, or 1 if it hasn't been set. This is supported by PDF 1.6
+ * and higher.
+ *
+ * @return the user unit.
+ */
+ public float getUserUnit()
+ {
+ float userUnit = page.getFloat(COSName.USER_UNIT, 1.0f);
+ return userUnit > 0 ? userUnit : 1.0f;
+ }
+
+ /**
+ * Get the user unit. This is a positive number that shall give the size of default user space
+ * units, in multiples of 1/72 inch. This is supported by PDF 1.6 and higher.
+ *
+ * @param userUnit
+ * throws IllegalArgumentException if the parameter is not positive.
+ */
+ public void setUserUnit(float userUnit)
+ {
+ if (userUnit <= 0)
+ {
+ throw new IllegalArgumentException("User unit must be positive");
+ }
+ page.setFloat(COSName.USER_UNIT, userUnit);
+ }
}