public void accept(IVisitor visitor) { if (this.base != null) { this.base.accept(visitor); } }
public COSObject at(final int i) { return this.base != null ? this.base.at(i) : this; }
public Boolean getBooleanKey(final ASAtom key) { return this.base != null ? this.base.getBooleanKey(key) : null; }
private static boolean isMarkedContentAFKeyAndValueTypeCorrect(COSBase tag, COSBase propKey) { if (tag == null || propKey == null) { return false; } else if (tag.getType() != COSObjType.COS_NAME || propKey.getType() != COSObjType.COS_NAME) { return false; } else if (ASAtom.AF != tag.getName()) { return false; } return true; }
@Override public Long getrenderingMode() { if (!this.arguments.isEmpty()) { COSBase renderingMode = this.arguments.get(0); if (renderingMode.getType() == COSObjType.COS_INTEGER) { return renderingMode.getInteger(); } } return null; }
COSObject decodeParmsObject = this.baseObject.getKey(ASAtom.DECODE_PARMS); COSBase decodeParms = null; if (decodeParmsObject != null) { decodeParms = decodeParms.at(0).get(); result.add(createFilter((COSName) COSName.fromValue(filter), null)); } else if (decodeParms.getType() == COSObjType.COS_ARRAY && decodeParms.size().intValue() > i) { decodeParms = decodeParms.at(i).get(); result.add(createFilter((COSName) COSName.fromValue(filter), decodeParms)); } else {
/** * @return a rectangle, expressed in the glyph coordinate system, that shall * specify the font bounding box. */ public double[] getFontBoundingBox() { if (fontBoundingBox == null) { COSBase bbox = this.getObject().getKey(ASAtom.FONT_BBOX).get(); if (bbox != null && bbox.getType() == COSObjType.COS_ARRAY && bbox.size() == 4) { double[] res = new double[4]; for (int i = 0; i < 4; ++i) { COSObject obj = bbox.at(i); if (obj.getType().isNumber()) { res[i] = obj.getReal(); } else { LOGGER.log(Level.SEVERE, "Font bounding box array for font " + fontName + " contains " + obj.getType()); return null; } } fontBoundingBox = res; } else { LOGGER.log(Level.SEVERE, "Font bounding box array for font " + fontName + " is not an array of 4 elements"); return null; } } return fontBoundingBox; }
/** * Gets encoding object from COSObject. * * @param e is value of Encoding key in font dictionary. * @return encoding object for given COSObject. */ private static Encoding getEncodingMappingFromCOSObject(COSObject e) { Encoding encodingObj; COSBase cosEncoding = e.getDirectBase(); if (cosEncoding != null) { if (cosEncoding.getType() == COSObjType.COS_NAME) { encodingObj = new Encoding(cosEncoding.getName()); return encodingObj; } else if (cosEncoding.getType() == COSObjType.COS_DICT) { encodingObj = new Encoding(cosEncoding.getNameKey(ASAtom.BASE_ENCODING), getDifferencesFromCosEncoding(e)); return encodingObj; } } return null; }
private static List<byte[]> getStrings(List<COSBase> stringArgs) { if (!stringArgs.isEmpty()) { List<byte[]> res = new ArrayList<>(); COSBase arg = stringArgs.get(0); if (arg != null) { if (arg.getType() == COSObjType.COS_ARRAY) { GFOpTextShow.addArrayElements(res, (COSArray) arg.getDirectBase()); } else { if (arg.getType() == COSObjType.COS_STRING) { res.add(((COSString) (arg.getDirectBase())).get()); } } } return res; } return Collections.emptyList(); }
/** * Get all keys of the dictionary */ private List<CosName> getKeys() { List<CosName> list = new ArrayList<>(this.baseObject.size().intValue()); for (ASAtom key : this.baseObject.getKeySet()) { if (key != null) { COSBase name = COSName.fromValue(key); list.add((CosName) getFromValue(name)); } } return Collections.unmodifiableList(list); }
/** * Transform object of pdf box to corresponding object of abstract model * implementation. For transforming using {@code PBCosVisitor}. * * @param base * @return object of abstract model implementation, transformed from * {@code base} */ public static CosObject getFromValue(COSBase base) { if (base != null) { GFCosVisitor visitor = GFCosVisitor.getInstance(); if (base.isIndirect().booleanValue()) { return (CosObject) GFCosVisitor.visitFromIndirect((COSIndirect) base); } return (CosObject) base.accept(visitor); } return null; }
@Override public Boolean getMarked() { if (this.catalog != null) { COSObject markInfoObject = this.catalog.getKey(ASAtom.MARK_INFO); if (markInfoObject == null || markInfoObject.empty()) { return Boolean.FALSE; } COSBase markInfo = markInfoObject.getDirectBase(); if (markInfo.getType() == COSObjType.COS_DICT) { return markInfo.getBooleanKey(ASAtom.MARKED); } LOGGER.log(Level.WARNING, "MarkedInfo must be a 'COSDictionary' but got: " + markInfoObject.getType()); return Boolean.FALSE; } return Boolean.FALSE; }
public COSKey getKey() { return this.base != null ? this.base.getKey() : null; }
public COSKey getObjectKey() { return this.base != null ? this.base.getObjectKey() : null; }
public Long getInteger() { return this.base != null ? this.base.getInteger() : null; }
public Set<ASAtom> getKeySet() { if (this.base != null) { return this.base.getKeySet(); } return null; }
public ASAtom getName() { return this.base != null ? this.base.getName() : null; }
public ASInputStream getData(final COSStream.FilterFlags flags) { return this.base != null ? this.base.getData(flags) : null; }
public COSBase getDirectBase() { return this.base != null ? this.base.getDirectBase() : null; }
private void initializePropertiesDict(PDResourcesHandler resources) { if (!this.arguments.isEmpty()) { COSBase lastArg = this.arguments.get(this.arguments.size() - 1); COSObjType lastArgType = lastArg.getType(); if (lastArgType == COSObjType.COS_DICT) { this.propertiesDict = (COSDictionary) lastArg; } else if (lastArgType == COSObjType.COS_NAME && resources != null) { PDResource properties = resources.getProperties(lastArg.getName()); if (properties != null) { COSBase cosProperties = properties.getObject().getDirectBase(); if (cosProperties != null && cosProperties.getType() == COSObjType.COS_DICT) { this.propertiesDict = (COSDictionary) cosProperties; } } } } }