use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class MoveTo method process.
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
if (operands.size() < 2) {
throw new MissingOperandException(operator, operands);
}
COSBase base0 = operands.get(0);
if (!(base0 instanceof COSNumber)) {
return;
}
COSBase base1 = operands.get(1);
if (!(base1 instanceof COSNumber)) {
return;
}
COSNumber x = (COSNumber) base0;
COSNumber y = (COSNumber) base1;
PointF pos = context.transformedPoint(x.floatValue(), y.floatValue());
context.moveTo(pos.x, pos.y);
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class COSArrayList method convertIntegerCOSArrayToList.
/**
* This will take an array of COSNumbers and return a COSArrayList of
* java.lang.Integer values.
*
* @param intArray The existing integer Array.
*
* @return A list that is part of the core Java collections.
*/
public static List<Integer> convertIntegerCOSArrayToList(COSArray intArray) {
List<Integer> retval = null;
if (intArray != null) {
List<Integer> numbers = new ArrayList<Integer>();
for (int i = 0; i < intArray.size(); i++) {
COSNumber num;
if (intArray.get(i) instanceof COSObject) {
num = (COSNumber) ((COSObject) intArray.get(i)).getObject();
} else {
num = (COSNumber) intArray.get(i);
}
numbers.add(num.intValue());
}
retval = new COSArrayList<Integer>(numbers, intArray);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class COSArrayList method convertFloatCOSArrayToList.
/**
* This will take an array of COSNumbers and return a COSArrayList of
* java.lang.Float values.
*
* @param floatArray The existing float Array.
*
* @return The list of Float objects.
*/
public static List<Float> convertFloatCOSArrayToList(COSArray floatArray) {
List<Float> retval = null;
if (floatArray != null) {
List<Float> numbers = new ArrayList<Float>(floatArray.size());
for (int i = 0; i < floatArray.size(); i++) {
COSBase base = floatArray.getObject(i);
if (base instanceof COSNumber) {
numbers.add(((COSNumber) base).floatValue());
} else {
numbers.add(null);
}
}
retval = new COSArrayList<Float>(numbers, floatArray);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class PDType3CharProc method getGlyphBBox.
/**
* Calculate the bounding box of this glyph. This will work only if the first operator in the
* stream is d1.
*
* @return the bounding box of this glyph, or null if the first operator is not d1.
* @throws IOException If an io error occurs while parsing the stream.
*/
public PDRectangle getGlyphBBox() throws IOException {
List<COSBase> arguments = new ArrayList<COSBase>();
PDFStreamParser parser = new PDFStreamParser(this);
Object token = parser.parseNextToken();
while (token != null) {
if (token instanceof COSObject) {
arguments.add(((COSObject) token).getObject());
} else if (token instanceof Operator) {
if (((Operator) token).getName().equals("d1") && arguments.size() == 6) {
for (int i = 0; i < 6; ++i) {
if (!(arguments.get(i) instanceof COSNumber)) {
return null;
}
}
return new PDRectangle(((COSNumber) arguments.get(2)).floatValue(), ((COSNumber) arguments.get(3)).floatValue(), ((COSNumber) arguments.get(4)).floatValue() - ((COSNumber) arguments.get(2)).floatValue(), ((COSNumber) arguments.get(5)).floatValue() - ((COSNumber) arguments.get(3)).floatValue());
} else {
return null;
}
} else {
arguments.add((COSBase) token);
}
token = parser.parseNextToken();
}
return null;
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class FDFField method getSetFieldFlags.
/**
* This will get the SetFf entry of the cos dictionary. If it it not present then this method will return null.
*
* @return The field flags.
*/
public Integer getSetFieldFlags() {
Integer retval = null;
COSNumber ff = (COSNumber) field.getDictionaryObject(COSName.SET_FF);
if (ff != null) {
retval = ff.intValue();
}
return retval;
}
Aggregations