use of com.tom_roush.pdfbox.cos.COSBase 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.COSBase in project PdfBox-Android by TomRoush.
the class ShowText method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
if (arguments.isEmpty()) {
// ignore ( )Tj
return;
}
COSBase base = arguments.get(0);
if (!(base instanceof COSString)) {
// ignore
return;
}
if (context.getTextMatrix() == null) {
// ignore: outside of BT...ET
return;
}
COSString string = (COSString) base;
context.showTextString(string.getBytes());
}
use of com.tom_roush.pdfbox.cos.COSBase 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.COSBase in project PdfBox-Android by TomRoush.
the class BeginMarkedContentSequence method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
COSName tag = null;
for (COSBase argument : arguments) {
if (argument instanceof COSName) {
tag = (COSName) argument;
}
}
context.beginMarkedContentSequence(tag, null);
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStream method getFileDecodeParams.
/**
* Get the list of decode parameters. Each entry in the list will refer to
* an entry in the filters list.
*
* @return The list of decode parameters.
* @throws IOException if there is an error retrieving the parameters.
*/
public List<Object> getFileDecodeParams() throws IOException {
List<Object> retval = null;
COSBase dp = stream.getDictionaryObject(COSName.F_DECODE_PARMS);
if (dp instanceof COSDictionary) {
Map<?, ?> map = COSDictionaryMap.convertBasicTypesToMap((COSDictionary) dp);
retval = new COSArrayList<Object>(map, dp, stream, COSName.F_DECODE_PARMS);
} else if (dp instanceof COSArray) {
COSArray array = (COSArray) dp;
List<Object> actuals = new ArrayList<Object>();
for (int i = 0; i < array.size(); i++) {
actuals.add(COSDictionaryMap.convertBasicTypesToMap((COSDictionary) array.getObject(i)));
}
retval = new COSArrayList<Object>(actuals, array);
}
return retval;
}
Aggregations