Search in sources :

Example 16 with COSFloat

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);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSFloat(com.tom_roush.pdfbox.cos.COSFloat) Test(org.junit.Test)

Example 17 with COSFloat

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);
}
Also used : MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) COSNumber(com.tom_roush.pdfbox.cos.COSNumber) ArrayList(java.util.ArrayList) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSFloat(com.tom_roush.pdfbox.cos.COSFloat)

Example 18 with COSFloat

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);
}
Also used : ArrayList(java.util.ArrayList) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSFloat(com.tom_roush.pdfbox.cos.COSFloat)

Example 19 with COSFloat

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));
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSFloat(com.tom_roush.pdfbox.cos.COSFloat)

Example 20 with COSFloat

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));
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSFloat(com.tom_roush.pdfbox.cos.COSFloat)

Aggregations

COSFloat (com.tom_roush.pdfbox.cos.COSFloat)20 COSArray (com.tom_roush.pdfbox.cos.COSArray)16 COSBase (com.tom_roush.pdfbox.cos.COSBase)5 COSBoolean (com.tom_roush.pdfbox.cos.COSBoolean)2 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)2 COSName (com.tom_roush.pdfbox.cos.COSName)2 COSString (com.tom_roush.pdfbox.cos.COSString)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)1 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)1 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 COSNumber (com.tom_roush.pdfbox.cos.COSNumber)1 PDColor (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1