use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDLineDashPatternTest method testGetCOSObject.
/**
* Test of getCOSObject method, of class PDLineDashPattern.
*/
@Test
public void testGetCOSObject() {
COSArray ar = new COSArray();
ar.add(COSInteger.ONE);
ar.add(COSInteger.TWO);
PDLineDashPattern dash = new PDLineDashPattern(ar, 3);
COSArray dashBase = (COSArray) dash.getCOSObject();
COSArray dashArray = (COSArray) dashBase.getObject(0);
assertEquals(2, dashBase.size());
assertEquals(2, dashArray.size());
assertEquals(new COSFloat(1), dashArray.get(0));
assertEquals(new COSFloat(2), dashArray.get(1));
assertEquals(COSInteger.THREE, dashBase.get(1));
System.out.println(dash);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class MoveTextSetLeading method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
if (arguments.size() < 2) {
throw new MissingOperandException(operator, arguments);
}
// move text position and set leading
COSBase base1 = arguments.get(1);
if (!(base1 instanceof COSNumber)) {
return;
}
COSNumber y = (COSNumber) base1;
List<COSBase> args = new ArrayList<COSBase>();
args.add(new COSFloat(-1 * y.floatValue()));
context.processOperator(OperatorName.SET_TEXT_LEADING, args);
context.processOperator(OperatorName.MOVE_TEXT, arguments);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class NextLine method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
// move to start of next text line
List<COSBase> args = new ArrayList<COSBase>();
args.add(new COSFloat(0f));
// this must be -leading instead of just leading as written in the
// specification (p.369) the acrobat reader seems to implement it the same way
args.add(new COSFloat(-1 * context.getGraphicsState().getTextState().getLeading()));
// use Td instead of repeating code
context.processOperator(OperatorName.MOVE_TEXT, args);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDAnnotationLine method setCaptionVerticalOffset.
/**
* This will set the vertical offset of the caption.
*
* @param offset vertical offset of the caption
*/
public void setCaptionVerticalOffset(float offset) {
COSArray array = (COSArray) this.getCOSObject().getDictionaryObject(COSName.CO);
if (array == null) {
array = new COSArray();
array.setFloatArray(new float[] { 0.f, offset });
this.getCOSObject().setItem(COSName.CO, array);
} else {
array.set(1, new COSFloat(offset));
}
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDAnnotationLine method setCaptionHorizontalOffset.
/**
* This will set the horizontal offset of the caption.
*
* @param offset the horizontal offset of the caption
*/
public void setCaptionHorizontalOffset(float offset) {
COSArray array = (COSArray) this.getCOSObject().getDictionaryObject(COSName.CO);
if (array == null) {
array = new COSArray();
array.setFloatArray(new float[] { offset, 0.f });
this.getCOSObject().setItem(COSName.CO, array);
} else {
array.set(0, new COSFloat(offset));
}
}
Aggregations