Search in sources :

Example 31 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDSeedValueCertificate method removeOID.

/**
 * removes an OID from the list
 *
 * @param oid the object identifier to be removed.
 */
public void removeOID(byte[] oid) {
    COSBase base = this.dictionary.getDictionaryObject(COSName.OID);
    if (base instanceof COSArray) {
        COSArray array = (COSArray) base;
        array.remove(new COSString(oid));
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 32 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDSeedValueCertificate method addIssuer.

/**
 * array of bytes containing DER-encoded X.509v3 certificates of acceptable issuers. If the
 * signer’s certificate chains up to any of the specified issuers (either directly or
 * indirectly), the certificate is considered acceptable for signing.
 *
 * @param issuer A byte array containing DER-encoded X.509v3 certificate
 */
public void addIssuer(byte[] issuer) {
    COSBase base = this.dictionary.getDictionaryObject(COSName.ISSUER);
    COSArray array;
    if (base instanceof COSArray) {
        array = (COSArray) base;
    } else {
        array = new COSArray();
    }
    COSString string = new COSString(issuer);
    array.add(string);
    this.dictionary.setItem(COSName.ISSUER, array);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 33 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDSeedValueCertificate method removeIssuer.

/**
 * Removes an issuer from the issuers list
 *
 * @param issuer A byte array containing DER-encoded X.509v3 certificate
 */
public void removeIssuer(byte[] issuer) {
    COSBase base = this.dictionary.getDictionaryObject(COSName.ISSUER);
    if (base instanceof COSArray) {
        COSArray array = (COSArray) base;
        array.remove(new COSString(issuer));
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 34 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class Filter method getDecodeParams.

// gets the decode params for a specific filter index, this is used to
// normalise the DecodeParams entry so that it is always a dictionary
protected COSDictionary getDecodeParams(COSDictionary dictionary, int index) {
    COSBase filter = dictionary.getDictionaryObject(COSName.FILTER, COSName.F);
    COSBase obj = dictionary.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
    if (filter instanceof COSName && obj instanceof COSDictionary) {
        // but tests show that Adobe means "one filter name object".
        return (COSDictionary) obj;
    } else if (filter instanceof COSArray && obj instanceof COSArray) {
        COSArray array = (COSArray) obj;
        if (index < array.size()) {
            COSBase objAtIndex = array.getObject(index);
            if (objAtIndex instanceof COSDictionary) {
                return (COSDictionary) array.getObject(index);
            }
        }
    } else if (obj != null && !(filter instanceof COSArray || obj instanceof COSArray)) {
        Log.e("PdfBox-Android", "Expected DecodeParams to be an Array or Dictionary but found " + obj.getClass().getName());
    }
    return new COSDictionary();
}
Also used : COSName(com.tom_roush.pdfbox.cos.COSName) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 35 with COSBase

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

Aggregations

COSBase (com.tom_roush.pdfbox.cos.COSBase)215 COSArray (com.tom_roush.pdfbox.cos.COSArray)108 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)68 COSName (com.tom_roush.pdfbox.cos.COSName)50 COSObject (com.tom_roush.pdfbox.cos.COSObject)42 IOException (java.io.IOException)34 COSString (com.tom_roush.pdfbox.cos.COSString)33 COSNumber (com.tom_roush.pdfbox.cos.COSNumber)29 ArrayList (java.util.ArrayList)29 COSStream (com.tom_roush.pdfbox.cos.COSStream)20 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)14 MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)11 HashMap (java.util.HashMap)11 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)10 Map (java.util.Map)10 List (java.util.List)9 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)8 COSFloat (com.tom_roush.pdfbox.cos.COSFloat)7 COSObjectKey (com.tom_roush.pdfbox.cos.COSObjectKey)7 PDFStreamParser (com.tom_roush.pdfbox.pdfparser.PDFStreamParser)6