Author: tilman Date: Sun Dec 15 08:52:43 2019 New Revision: 1871574 URL: http://svn.apache.org/viewvc?rev=1871574&view=rev Log: PDFBOX-4706: add getter/setter for UserUnit
Modified: pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Modified: pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1871574&r1=1871573&r2=1871574&view=diff ============================================================================== --- pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original) +++ pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Sun Dec 15 08:52:43 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); + } }