Search in sources :

Example 81 with COSBase

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

the class PDActionGoTo method setDestination.

/**
 * This will set the destination to jump to.
 *
 * @param d The destination.
 *
 * @throws IllegalArgumentException if the destination is not a page dictionary object.
 */
public void setDestination(PDDestination d) {
    if (d instanceof PDPageDestination) {
        PDPageDestination pageDest = (PDPageDestination) d;
        COSArray destArray = pageDest.getCOSObject();
        if (destArray.size() >= 1) {
            COSBase page = destArray.getObject(0);
            if (!(page instanceof COSDictionary)) {
                throw new IllegalArgumentException("Destination of a GoTo action must be " + "a page dictionary object");
            }
        }
    }
    getCOSObject().setItem(COSName.D, d);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) PDPageDestination(com.tom_roush.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageDestination) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 82 with COSBase

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

the class PDTilingPattern method getBBox.

/**
 * An array of four numbers in the form coordinate system (see
 * below), giving the coordinates of the left, bottom, right, and top edges,
 * respectively, of the pattern's bounding box.
 *
 * @return The BBox of the pattern.
 */
@Override
public PDRectangle getBBox() {
    PDRectangle retval = null;
    COSBase base = getCOSObject().getDictionaryObject(COSName.BBOX);
    if (base instanceof COSArray) {
        retval = new PDRectangle((COSArray) base);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle)

Example 83 with COSBase

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

the class PDShading method getColorSpace.

/**
 * This will get the color space or null if none exists.
 *
 * @return the color space for the shading
 * @throws IOException if there is an error getting the color space
 */
public PDColorSpace getColorSpace() throws IOException {
    if (colorSpace == null) {
        COSBase colorSpaceDictionary = dictionary.getDictionaryObject(COSName.CS, COSName.COLORSPACE);
        colorSpace = PDColorSpace.create(colorSpaceDictionary);
    }
    return colorSpace;
}
Also used : COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 84 with COSBase

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

the class PDFontSetting method getFont.

/**
 * This will get the font for this font setting.
 *
 * @return The font for this setting of null if one was not found.
 *
 * @throws IOException If there is an error getting the font.
 */
public PDFont getFont() throws IOException {
    PDFont retval = null;
    COSBase font = fontSetting.getObject(0);
    if (font instanceof COSDictionary) {
        retval = PDFontFactory.createFont((COSDictionary) font);
    }
    return retval;
}
Also used : PDFont(com.tom_roush.pdfbox.pdmodel.font.PDFont) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 85 with COSBase

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

the class PDButton method getExportValues.

/**
 * This will get the (optional) export values.
 *
 * <p>The export values are defined in the field dictionaries /Opt key.</p>
 *
 * <p>The option values are used to define the export values
 * for the field to
 * <ul>
 *  <li>hold values in non-Latin writing systems as name objects, which represent the field value, are limited
 *      to PDFDocEncoding
 *  </li>
 *  <li>allow radio buttons having the same export value to be handled independently
 *  </li>
 * </ul>
 *
 * @return List containing all possible export values. If there is no /Opt entry an empty list will be returned.
 *
 * @see #getOnValues()
 */
public List<String> getExportValues() {
    COSBase value = getInheritableAttribute(COSName.OPT);
    if (value instanceof COSString) {
        List<String> array = new ArrayList<String>();
        array.add(((COSString) value).getString());
        return array;
    } else if (value instanceof COSArray) {
        return COSArrayList.convertCOSStringCOSArrayToList((COSArray) value);
    }
    return Collections.emptyList();
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) ArrayList(java.util.ArrayList) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString) COSString(com.tom_roush.pdfbox.cos.COSString)

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