use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDResources method createKey.
/**
* Returns a unique key for a new resource.
*/
private COSName createKey(COSName kind, String prefix) {
COSDictionary dict = (COSDictionary) resources.getDictionaryObject(kind);
if (dict == null) {
return COSName.getPDFName(prefix + 1);
}
// find a unique key
String key;
int n = dict.keySet().size();
do {
++n;
key = prefix + n;
} while (dict.containsKey(key));
return COSName.getPDFName(key);
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDResources method put.
/**
* 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);
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDEmbeddedFile method setMacSubtype.
/**
* Set the mac subtype.
*
* @param macSubtype The mac subtype.
*/
public void setMacSubtype(String macSubtype) {
COSDictionary params = (COSDictionary) getCOSObject().getDictionaryObject(COSName.PARAMS);
if (params == null && macSubtype != null) {
params = new COSDictionary();
getCOSObject().setItem(COSName.PARAMS, params);
}
if (params != null) {
params.setEmbeddedString("Mac", "Subtype", macSubtype);
}
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDEmbeddedFile method getMacCreator.
/**
* Get the mac Creator.
*
* @return The mac Creator.
*/
public String getMacCreator() {
String retval = null;
COSDictionary params = (COSDictionary) getCOSObject().getDictionaryObject(COSName.PARAMS);
if (params != null) {
retval = params.getEmbeddedString("Mac", "Creator");
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class COSDictionaryMap method convert.
/**
* This will take a map<java.lang.String,com.tom_roush.pdfbox.pdmodel.COSObjectable>
* and convert it into a COSDictionary.
*
* @param someMap A map containing COSObjectables
*
* @return A proper COSDictionary
*/
public static COSDictionary convert(Map<String, ?> someMap) {
COSDictionary dic = new COSDictionary();
for (Entry<String, ?> entry : someMap.entrySet()) {
String name = entry.getKey();
COSObjectable object = (COSObjectable) entry.getValue();
dic.setItem(COSName.getPDFName(name), object.getCOSObject());
}
return dic;
}
Aggregations