Refine search
/** * This will get the transfer function of the /TR dictionary. * * @return The transfer function. According to the PDF specification, this is either a single * function (which applies to all process colorants) or an array of four functions (which apply * to the process colorants individually). The name Identity may be used to represent the * identity function. */ public COSBase getTransfer() { COSBase base = dict.getDictionaryObject(COSName.TR); if (base instanceof COSArray && ((COSArray) base).size() != 4) { return null; } return base; }
/** * Sets the value of a given named resource. */ private void put(COSName kind, COSName name, COSObjectable object) { COSDictionary dict = (COSDictionary)resources.getDictionaryObject(kind); if (dict == null) { dict = new COSDictionary(); resources.setItem(kind, dict); } dict.setItem(name, object); }
/** * Update the P reference to the new parent dictionary. * * @param kArray the kids array * @param newParent the new parent */ private void updateParentEntry(COSArray kArray, COSDictionary newParent) { for (int i = 0; i < kArray.size(); i++) { COSBase subEntry = kArray.getObject(i); if (subEntry instanceof COSDictionary) { COSDictionary dictEntry = (COSDictionary) subEntry; if (dictEntry.getDictionaryObject(COSName.P) != null) { dictEntry.setItem(COSName.P, newParent); } } } }
/** * @return The Additional Actions for this Document */ public PDDocumentCatalogAdditionalActions getActions() { COSDictionary addAction = (COSDictionary) root.getDictionaryObject(COSName.AA); if (addAction == null) { addAction = new COSDictionary(); root.setItem(COSName.AA, addAction); } return new PDDocumentCatalogAdditionalActions(addAction); }
/** * This will get the transfer function of the /TR2 dictionary. * * @return The transfer function. According to the PDF specification, this is either a single * function (which applies to all process colorants) or an array of four functions (which apply * to the process colorants individually). The name Identity may be used to represent the * identity function, and the name Default denotes the transfer function that was in effect at * the start of the page. */ public COSBase getTransfer2() { COSBase base = dict.getDictionaryObject(COSName.TR2); if (base instanceof COSArray && ((COSArray) base).size() != 4) { return null; } return base; }
/** * Returns the document's article threads. */ public List<PDThread> getThreads() { COSArray array = (COSArray)root.getDictionaryObject(COSName.THREADS); if (array == null) { array = new COSArray(); root.setItem(COSName.THREADS, array); } List<PDThread> pdObjects = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { pdObjects.add(new PDThread((COSDictionary)array.getObject(i))); } return new COSArrayList<>(pdObjects, array); }
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; }
/** * Read out the byterange from the file. * * @return a integer array with the byterange */ public int[] getByteRange() { COSArray byteRange = (COSArray)dictionary.getDictionaryObject(COSName.BYTERANGE); int[] ary = new int[byteRange.size()]; for (int i = 0; i<ary.length;++i) { ary[i] = byteRange.getInt(i); } return ary; }
/** * This will set the line ending style for the start point, see the LE_ constants for the possible values. * * @param style The new style. */ public void setStartPointEndingStyle(String style) { String actualStyle = style == null ? PDAnnotationLine.LE_NONE : style; COSBase base = getCOSObject().getDictionaryObject(COSName.LE); COSArray array; if (!(base instanceof COSArray) || ((COSArray) base).size() == 0) { array = new COSArray(); array.add(COSName.getPDFName(actualStyle)); array.add(COSName.getPDFName(PDAnnotationLine.LE_NONE)); getCOSObject().setItem(COSName.LE, array); } else { array = (COSArray) base; array.setName(0, actualStyle); } }
/** * Sets the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * @param cryptFilterDictionary the crypt filter to set */ public void setCryptFilterDictionary(COSName cryptFilterName, PDCryptFilterDictionary cryptFilterDictionary) { COSDictionary cfDictionary = (COSDictionary)dictionary.getDictionaryObject( COSName.CF ); if (cfDictionary == null) { cfDictionary = new COSDictionary(); dictionary.setItem(COSName.CF, cfDictionary); } cfDictionary.setItem(cryptFilterName, cryptFilterDictionary.getCOSDictionary()); }
/** * Returns true if this page has contents. */ public boolean hasContents() { COSBase contents = page.getDictionaryObject(COSName.CONTENTS); if (contents instanceof COSStream) { return ((COSStream) contents).size() > 0; } else if (contents instanceof COSArray) { return ((COSArray) contents).size() > 0; } return false; }
/** * This will set the line ending style for the start point, see the LE_ constants for the possible values. * * @param style The new style. */ public void setStartPointEndingStyle(String style) { String actualStyle = style == null ? PDAnnotationLine.LE_NONE : style; COSBase base = getCOSObject().getDictionaryObject(COSName.LE); COSArray array; if (!(base instanceof COSArray) || ((COSArray) base).size() == 0) { array = new COSArray(); array.add(COSName.getPDFName(actualStyle)); array.add(COSName.getPDFName(PDAnnotationLine.LE_NONE)); getCOSObject().setItem(COSName.LE, array); } else { array = (COSArray) base; array.setName(0, actualStyle); } }
/** * This is a convenience method that will convert the value to a COSInteger object. * * @param embeddedDictionary The embedded dictionary. * @param key The key to the object, * @param value The int value for the name. */ public void setEmbeddedInt(String embeddedDictionary, COSName key, int value) { COSDictionary embedded = (COSDictionary) getDictionaryObject(embeddedDictionary); if (embedded == null) { embedded = new COSDictionary(); setItem(embeddedDictionary, embedded); } embedded.setInt(key, value); }
/** * This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section. * * @return The ending style for the end point, LE_NONE if missing, never null. */ public String getEndPointEndingStyle() { COSBase base = getCOSObject().getDictionaryObject(COSName.LE); if (base instanceof COSArray && ((COSArray) base).size() >= 2) { return ((COSArray) base).getName(1, PDAnnotationLine.LE_NONE); } return PDAnnotationLine.LE_NONE; }
/** * This will set the line ending style for the end point, see the LE_ constants for the possible values. * * @param style The new style. */ public void setEndPointEndingStyle(String style) { String actualStyle = style == null ? PDAnnotationLine.LE_NONE : style; COSBase base = getCOSObject().getDictionaryObject(COSName.LE); COSArray array; if (!(base instanceof COSArray) || ((COSArray) base).size() < 2) { array = new COSArray(); array.add(COSName.getPDFName(PDAnnotationLine.LE_NONE)); array.add(COSName.getPDFName(actualStyle)); getCOSObject().setItem(COSName.LE, array); } else { array = (COSArray) base; array.setName(1, actualStyle); } }
/** * Set the date object. * * @param embedded The embedded dictionary. * @param key The key to the date. * @param date The date to set. */ public void setEmbeddedDate(String embedded, COSName key, Calendar date) { COSDictionary dic = (COSDictionary) getDictionaryObject(embedded); if (dic == null && date != null) { dic = new COSDictionary(); setItem(embedded, dic); } if (dic != null) { dic.setDate(key, date); } }
/** * This will retrieve the line ending style for the start point, possible values shown in the LE_ constants section. * * @return The ending style for the start point, LE_NONE if missing, never null. */ public String getStartPointEndingStyle() { COSBase base = getCOSObject().getDictionaryObject(COSName.LE); if (base instanceof COSArray && ((COSArray) base).size() >= 2) { return ((COSArray) base).getName(0, PDAnnotationLine.LE_NONE); } return PDAnnotationLine.LE_NONE; }
/** * This will set the line ending style for the end point, see the LE_ constants for the possible values. * * @param style The new style. */ public void setEndPointEndingStyle(String style) { String actualStyle = style == null ? PDAnnotationLine.LE_NONE : style; COSBase base = getCOSObject().getDictionaryObject(COSName.LE); COSArray array; if (!(base instanceof COSArray) || ((COSArray) base).size() < 2) { array = new COSArray(); array.add(COSName.getPDFName(PDAnnotationLine.LE_NONE)); array.add(COSName.getPDFName(actualStyle)); getCOSObject().setItem(COSName.LE, array); } else { array = (COSArray) base; array.setName(1, actualStyle); } }
/** * Get the page actions. * * @return The Actions for this Page */ public PDPageAdditionalActions getActions() { COSDictionary addAct; COSBase base = page.getDictionaryObject(COSName.AA); if (base instanceof COSDictionary) { addAct = (COSDictionary) base; } else { addAct = new COSDictionary(); page.setItem(COSName.AA, addAct); } return new PDPageAdditionalActions(addAct); }
/** * This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section. * * @return The ending style for the end point, LE_NONE if missing, never null. */ public String getEndPointEndingStyle() { COSBase base = getCOSObject().getDictionaryObject(COSName.LE); if (base instanceof COSArray && ((COSArray) base).size() >= 2) { return ((COSArray) base).getName(1, LE_NONE); } return LE_NONE; }