/** * Return true if the Count entry is present in the given dictionary. * * @param outline the dictionary representing the document outline. * @return true if the Count entry is present. */ private boolean isCountEntryPresent(COSDictionary outline) { return outline.getItem(COSName.COUNT) != null; }
/** * This will get the dictionary object in this object that has the name key. * * @param key The key to the value that we are searching for. * * @return The pdf object that matches the key. */ public COSBase getItem( COSName key ) { COSBase retval =null; if( baseObject instanceof COSDictionary ) { retval = ((COSDictionary)baseObject).getItem( key ); } return retval; }
/** * This is a convenience method that will get the dictionary object that is expected to be a COSObject. Null is * returned if the entry does not exist in the dictionary. * * @param key The key to the item in the dictionary. * @return The COSObject. */ public COSObject getCOSObject(COSName key) { COSBase object = getItem(key); if (object instanceof COSObject) { return (COSObject) object; } return null; }
/** * Creates a new instance based on a given {@link COSDictionary}. * @param dict the dictionary */ public PDOptionalContentGroup(COSDictionary dict) { super(dict); if (!dict.getItem(COSName.TYPE).equals(COSName.OCG)) { throw new IllegalArgumentException( "Provided dictionary is not of type '" + COSName.OCG + "'"); } }
/** * Returns the number of recipients contained in the Recipients field of the dictionary. * * @return the number of recipients contained in the Recipients field. */ public int getRecipientsLength() { COSArray array = (COSArray) dictionary.getItem(COSName.RECIPIENTS); return array.size(); }
/** * returns the COSString contained in the Recipients field at position i. * * @param i the position in the Recipients field array. * * @return a COSString object containing information about the recipient number i. */ public COSString getRecipientStringAt(int i) { COSArray array = (COSArray) dictionary.getItem(COSName.RECIPIENTS); return (COSString)array.get(i); }
/** * This will do a lookup into the dictionary. * * @param key The key to the object. * * @return The item that matches the key. */ public COSBase getItem(String key) { return getItem(COSName.getPDFName(key)); }
private void addExcludedToList(COSName[] excludeObjects, COSDictionary dict, final Set<Long> parsedObjects) { if (excludeObjects != null) { for (COSName objName : excludeObjects) { COSBase baseObj = dict.getItem(objName); if (baseObj instanceof COSObject) { parsedObjects.add(getObjectId((COSObject) baseObj)); } } } }
/** * @return the direction in which the specified transition effect shall moves. It can be either a {@link COSInteger} * or {@link COSName#NONE}. Default to {@link COSInteger#ZERO} * @see PDTransitionDirection */ public COSBase getDirection() { COSBase item = getCOSObject().getItem(COSName.DI); if (item == null) { return COSInteger.ZERO; } return item; }
/** * Returns the base state for optional content groups. * @return the base state */ public BaseState getBaseState() { COSDictionary d = getD(); COSName name = (COSName)d.getItem(COSName.BASE_STATE); return BaseState.valueOf(name); }
private COSArray getOCGs() { COSArray ocgs = (COSArray)this.dict.getItem(COSName.OCGS); if (ocgs == null) { ocgs = new COSArray(); this.dict.setItem(COSName.OCGS, ocgs); //OCGs is required } return ocgs; }
/** * Check the CMap entry. * * The CMap entry must be a dictionary in a PDF/A. This entry can be a String only if the String value is Identity-H * or Identity-V */ @Override protected void checkEncoding() { COSBase encoding = (font.getCOSObject()).getItem(COSName.ENCODING); checkCMapEncoding(encoding); }
@Override protected boolean innerValid() { COSBase f = this.actionDictionnary.getItem(COSName.F); if (f == null) { context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY, "F entry is mandatory for the SubmitActions")); return false; } return true; }
/** * Check the TR entry. A valid ExtGState hasn't TR entry. * * @param context the preflight context * @param egs the graphic state to check */ protected void checkTRKey(PreflightContext context, COSDictionary egs) { if (egs.getItem(COSName.TR) != null) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_UNEXPECTED_KEY, "No TR key expected in Extended graphics state")); } }
/** * This will get the margin between the annotations "outer" rectangle defined by * /Rect and the boundaries of the underlying caret. * * @return the differences. If the entry hasn't been set am empty array is returned. */ public float[] getRectDifferences() { COSBase margin = getCOSObject().getItem(COSName.RD); if (margin instanceof COSArray) { return ((COSArray) margin).toFloatArray(); } return new float[]{}; }
/** * This will get the margin between the annotations "outer" rectangle defined by * /Rect and the border. * * @return the differences. If the entry hasn't been set am empty array is returned. */ public float[] getRectDifferences() { COSBase margin = getCOSObject().getItem(COSName.RD); if (margin instanceof COSArray) { return ((COSArray) margin).toFloatArray(); } return new float[]{}; }
/** * This will get the differences between the annotations "outer" rectangle defined by * /Rect and the border. * * @return the differences. If the entry hasn't been set am empty array is returned. */ public float[] getRectDifferences() { COSBase margin = getCOSObject().getItem(COSName.RD); if (margin instanceof COSArray) { return ((COSArray) margin).toFloatArray(); } return new float[]{}; }
private boolean checkIndirectObject(PreflightContext ctx, COSDictionary dictionary, COSName name) { COSBase item = dictionary.getItem(name); if (item == null || item instanceof COSNull || item instanceof COSObject) { return true; } addValidationError(ctx, new ValidationError(ERROR_SYNTAX_TRAILER_OUTLINES_INVALID, "/" + name.getName() + " entry must be an indirect object")); return false; }
@Override protected boolean innerValid() throws ValidationException { COSBase dest = this.actionDictionnary.getItem(COSName.D); // ---- D entry is mandatory if (dest == null) { context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY, "D entry is mandatory for the GoToActions")); return false; } ContextHelper.validateElement(context, dest, DESTINATION_PROCESS); return true; }
/** * return true if Count entry > 0 * * @param ctx the preflight context. * @param outline the dictionary representing the document outline. * @return true if the Count entry > 0. */ private boolean isCountEntryPositive(PreflightContext ctx, COSDictionary outline) { COSBase countBase = outline.getItem(COSName.COUNT); COSDocument cosDocument = ctx.getDocument().getDocument(); return COSUtils.isInteger(countBase, cosDocument) && (COSUtils.getAsInteger(countBase, cosDocument) > 0); }