use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class SetLineWidth method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
if (arguments.isEmpty()) {
throw new MissingOperandException(operator, arguments);
}
COSNumber width = (COSNumber) arguments.get(0);
context.getGraphicsState().setLineWidth(width.floatValue());
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class SetMatrix method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
if (!checkArrayTypesClass(arguments, COSNumber.class)) {
return;
}
COSNumber a = (COSNumber) arguments.get(0);
COSNumber b = (COSNumber) arguments.get(1);
COSNumber c = (COSNumber) arguments.get(2);
COSNumber d = (COSNumber) arguments.get(3);
COSNumber e = (COSNumber) arguments.get(4);
COSNumber f = (COSNumber) arguments.get(5);
Matrix matrix = new Matrix(a.floatValue(), b.floatValue(), c.floatValue(), d.floatValue(), e.floatValue(), f.floatValue());
context.setTextMatrix(matrix);
context.setTextLineMatrix(matrix.clone());
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class MoveText method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException {
if (arguments.size() < 2) {
throw new MissingOperandException(operator, arguments);
}
Matrix textLineMatrix = context.getTextLineMatrix();
if (textLineMatrix == null) {
Log.w("PdfBox-Android", "TextLineMatrix is null, " + getName() + " operator will be ignored");
return;
}
COSBase base0 = arguments.get(0);
COSBase base1 = arguments.get(1);
if (!(base0 instanceof COSNumber)) {
return;
}
if (!(base1 instanceof COSNumber)) {
return;
}
COSNumber x = (COSNumber) base0;
COSNumber y = (COSNumber) base1;
Matrix matrix = new Matrix(1, 0, 0, 1, x.floatValue(), y.floatValue());
textLineMatrix.concatenate(matrix);
context.setTextMatrix(textLineMatrix.clone());
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class SetLineDashPattern method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException {
if (arguments.size() < 2) {
throw new MissingOperandException(operator, arguments);
}
COSBase base0 = arguments.get(0);
if (!(base0 instanceof COSArray)) {
return;
}
COSBase base1 = arguments.get(1);
if (!(base1 instanceof COSNumber)) {
return;
}
COSArray dashArray = (COSArray) base0;
int dashPhase = ((COSNumber) base1).intValue();
boolean allZero = true;
for (COSBase base : dashArray) {
if (base instanceof COSNumber) {
COSNumber num = (COSNumber) base;
if (num.floatValue() != 0) {
allZero = false;
break;
}
} else {
Log.w("PdfBox-Android", "dash array has non number element " + base + ", ignored");
dashArray = new COSArray();
break;
}
}
if (dashArray.size() > 0 && allZero) {
Log.w("PdfBox-Android", "dash lengths all zero, ignored");
dashArray = new COSArray();
}
context.setLineDashPattern(dashArray, dashPhase);
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class SetTextHorizontalScaling method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
if (arguments.isEmpty()) {
throw new MissingOperandException(operator, arguments);
}
COSNumber scaling = (COSNumber) arguments.get(0);
context.getGraphicsState().getTextState().setHorizontalScaling(scaling.floatValue());
}
Aggregations