use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException 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.contentstream.operator.MissingOperandException in project PdfBox-Android by TomRoush.
the class AppendRectangleToPath method process.
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
if (operands.size() < 4) {
throw new MissingOperandException(operator, operands);
}
if (!checkArrayTypesClass(operands, COSNumber.class)) {
return;
}
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
COSNumber w = (COSNumber) operands.get(2);
COSNumber h = (COSNumber) operands.get(3);
float x1 = x.floatValue();
float y1 = y.floatValue();
// create a pair of coordinates for the transformation
float x2 = w.floatValue() + x1;
float y2 = h.floatValue() + y1;
PointF p0 = context.transformedPoint(x1, y1);
PointF p1 = context.transformedPoint(x2, y1);
PointF p2 = context.transformedPoint(x2, y2);
PointF p3 = context.transformedPoint(x1, y2);
context.appendRectangle(p0, p1, p2, p3);
}
use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException in project PdfBox-Android by TomRoush.
the class CurveTo method process.
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
if (operands.size() < 6) {
throw new MissingOperandException(operator, operands);
}
if (!checkArrayTypesClass(operands, COSNumber.class)) {
return;
}
COSNumber x1 = (COSNumber) operands.get(0);
COSNumber y1 = (COSNumber) operands.get(1);
COSNumber x2 = (COSNumber) operands.get(2);
COSNumber y2 = (COSNumber) operands.get(3);
COSNumber x3 = (COSNumber) operands.get(4);
COSNumber y3 = (COSNumber) operands.get(5);
PointF point1 = context.transformedPoint(x1.floatValue(), y1.floatValue());
PointF point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
PointF point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());
if (context.getCurrentPoint() == null) {
Log.w("PdfBox-Android", "curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo");
context.moveTo(point3.x, point3.y);
} else {
context.curveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
}
}
use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException in project PdfBox-Android by TomRoush.
the class CurveToReplicateInitialPoint method process.
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
if (operands.size() < 4) {
throw new MissingOperandException(operator, operands);
}
if (!checkArrayTypesClass(operands, COSNumber.class)) {
return;
}
COSNumber x2 = (COSNumber) operands.get(0);
COSNumber y2 = (COSNumber) operands.get(1);
COSNumber x3 = (COSNumber) operands.get(2);
COSNumber y3 = (COSNumber) operands.get(3);
PointF currentPoint = context.getCurrentPoint();
PointF point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
PointF point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());
if (currentPoint == null) {
Log.w("PdfBox-Android", "curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo");
context.moveTo(point3.x, point3.y);
} else {
context.curveTo((float) currentPoint.x, (float) currentPoint.y, point2.x, point2.y, point3.x, point3.y);
}
}
use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException in project PdfBox-Android by TomRoush.
the class SetFontAndSize method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
if (arguments.size() < 2) {
throw new MissingOperandException(operator, arguments);
}
COSBase base0 = arguments.get(0);
COSBase base1 = arguments.get(1);
if (!(base0 instanceof COSName)) {
return;
}
if (!(base1 instanceof COSNumber)) {
return;
}
COSName fontName = (COSName) base0;
float fontSize = ((COSNumber) base1).floatValue();
context.getGraphicsState().getTextState().setFontSize(fontSize);
PDFont font = context.getResources().getFont(fontName);
if (font == null) {
Log.w("PdfBox-Android", "font '" + fontName.getName() + "' not found in resources");
}
context.getGraphicsState().getTextState().setFont(font);
}
Aggregations