use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.
the class PDCalGray method getGamma.
/**
* This will get the gamma value. If none is present then the default of 1
* will be returned.
*
* @return The gamma value.
*/
public float getGamma() {
float retval = 1.0f;
COSNumber gamma = (COSNumber) dictionary.getDictionaryObject(COSName.GAMMA);
if (gamma != null) {
retval = gamma.floatValue();
}
return retval;
}
use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.
the class PDAnnotation method getRectangle.
/**
* The annotation rectangle, defining the location of the annotation on the page in default user space units. This
* is usually required and should not return null on valid PDF documents. But where this is a parent form field with
* children, such as radio button collections then the rectangle will be null.
*
* @return The Rect value of this annotation.
*/
public PDRectangle getRectangle() {
COSArray rectArray = (COSArray) dictionary.getDictionaryObject(COSName.RECT);
PDRectangle rectangle = null;
if (rectArray != null) {
if (rectArray.size() == 4 && rectArray.getObject(0) instanceof COSNumber && rectArray.getObject(1) instanceof COSNumber && rectArray.getObject(2) instanceof COSNumber && rectArray.getObject(3) instanceof COSNumber) {
rectangle = new PDRectangle(rectArray);
} else {
LOG.warn(rectArray + " is not a rectangle array, returning null");
}
}
return rectangle;
}
use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.
the class PDExtendedGraphicsState method getLineDashPattern.
/**
* This will get the dash pattern.
*
* @return null or the D value in the dictionary.
*/
public PDLineDashPattern getLineDashPattern() {
PDLineDashPattern retval = null;
COSBase dp = dict.getDictionaryObject(COSName.D);
if (dp instanceof COSArray && ((COSArray) dp).size() == 2) {
COSBase dashArray = ((COSArray) dp).getObject(0);
COSBase phase = ((COSArray) dp).getObject(1);
if (dashArray instanceof COSArray && phase instanceof COSNumber) {
retval = new PDLineDashPattern((COSArray) dashArray, ((COSNumber) phase).intValue());
}
}
return retval;
}
use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.
the class PDAcroForm method getQ.
/**
* This will get the document-wide default value for the quadding/justification of variable text
* fields.
* <p>
* 0 - Left(default)<br>
* 1 - Centered<br>
* 2 - Right<br>
* See the QUADDING constants of {@link PDVariableText}.
*
* @return The justification of the variable text fields.
*/
public int getQ() {
int retval = 0;
COSNumber number = (COSNumber) dictionary.getDictionaryObject(COSName.Q);
if (number != null) {
retval = number.intValue();
}
return retval;
}
use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.
the class PDPolygonAppearanceHandler method getLineWidth.
/**
* Get the line with of the border.
*
* Get the width of the line used to draw a border around the annotation.
* This may either be specified by the annotation dictionaries Border
* setting or by the W entry in the BS border style dictionary. If both are
* missing the default width is 1.
*
* @return the line width
*/
// TODO: according to the PDF spec the use of the BS entry is annotation
// specific
// so we will leave that to be implemented by individual handlers.
// If at the end all annotations support the BS entry this can be handled
// here and removed from the individual handlers.
float getLineWidth() {
PDAnnotationPolygon annotation = (PDAnnotationPolygon) getAnnotation();
PDBorderStyleDictionary bs = annotation.getBorderStyle();
if (bs != null) {
return bs.getWidth();
} else {
COSArray borderCharacteristics = annotation.getBorder();
if (borderCharacteristics.size() >= 3) {
COSBase base = borderCharacteristics.getObject(2);
if (base instanceof COSNumber) {
return ((COSNumber) base).floatValue();
}
}
}
return 1;
}
Aggregations