use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDOptionalContentProperties method getD.
private COSDictionary getD() {
COSBase base = this.dict.getDictionaryObject(COSName.D);
if (base instanceof COSDictionary) {
return (COSDictionary) base;
}
COSDictionary d = new COSDictionary();
// Name optional but required for PDF/A-3
d.setString(COSName.NAME, "Top");
// D is required
this.dict.setItem(COSName.D, d);
return d;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDOptionalContentProperties method getOptionalContentGroups.
/**
* Returns the collection of all optional content groups.
* @return the optional content groups
*/
public Collection<PDOptionalContentGroup> getOptionalContentGroups() {
Collection<PDOptionalContentGroup> coll = new ArrayList<PDOptionalContentGroup>();
COSArray ocgs = getOCGs();
for (COSBase base : ocgs) {
coll.add(new PDOptionalContentGroup(toDictionary(base)));
}
return coll;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDImageXObject method getColorSpace.
@Override
public PDColorSpace getColorSpace() throws IOException {
if (colorSpace == null) {
COSBase cosBase = getCOSObject().getItem(COSName.COLORSPACE, COSName.CS);
if (cosBase != null) {
COSObject indirect = null;
if (cosBase instanceof COSObject && resources != null && resources.getResourceCache() != null) {
// PDFBOX-4022: use the resource cache because several images
// might have the same colorspace indirect object.
indirect = (COSObject) cosBase;
colorSpace = resources.getResourceCache().getColorSpace(indirect);
if (colorSpace != null) {
return colorSpace;
}
}
colorSpace = PDColorSpace.create(cosBase, resources);
if (indirect != null) {
resources.getResourceCache().put(indirect, colorSpace);
}
} else if (isStencil()) {
// stencil mask color space must be gray, it is often missing
return PDDeviceGray.INSTANCE;
} else {
// an image without a color space is always broken
throw new IOException("could not determine color space");
}
}
return colorSpace;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDExtendedGraphicsState method getFloatItem.
/**
* This will get a float item from the dictionary.
*
* @param key The key to the item.
*
* @return The value for that item.
*/
private Float getFloatItem(COSName key) {
Float retval = null;
COSBase base = dict.getDictionaryObject(key);
if (base instanceof COSNumber) {
COSNumber value = (COSNumber) base;
retval = value.floatValue();
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDAction method getNext.
/**
* This will get the next action, or sequence of actions, to be performed after this one.
* The value is either a single action dictionary or an array of action dictionaries
* to be performed in order.
*
* @return The Next action or sequence of actions.
*/
public List<PDAction> getNext() {
List<PDAction> retval = null;
COSBase next = action.getDictionaryObject(COSName.NEXT);
if (next instanceof COSDictionary) {
PDAction pdAction = PDActionFactory.createAction((COSDictionary) next);
retval = new COSArrayList<PDAction>(pdAction, next, action, COSName.NEXT);
} else if (next instanceof COSArray) {
COSArray array = (COSArray) next;
List<PDAction> actions = new ArrayList<PDAction>();
for (int i = 0; i < array.size(); i++) {
actions.add(PDActionFactory.createAction((COSDictionary) array.getObject(i)));
}
retval = new COSArrayList<PDAction>(actions, array);
}
return retval;
}
Aggregations