Search in sources :

Example 1 with PDAbstractPattern

use of com.tom_roush.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern in project PdfBox-Android by TomRoush.

the class PDResources method getPattern.

/**
 * Returns the pattern resource with the given name, or null if none exists.
 *
 * @param name Name of the pattern resource.
 *
 * @return the pattern resource of the given name.
 *
 * @throws IOException if something went wrong.
 */
public PDAbstractPattern getPattern(COSName name) throws IOException {
    COSObject indirect = getIndirect(COSName.PATTERN, name);
    if (cache != null && indirect != null) {
        PDAbstractPattern cached = cache.getPattern(indirect);
        if (cached != null) {
            return cached;
        }
    }
    // get the instance
    PDAbstractPattern pattern = null;
    COSDictionary dict = (COSDictionary) get(COSName.PATTERN, name);
    if (dict != null) {
        pattern = PDAbstractPattern.create(dict);
    }
    if (cache != null) {
        cache.put(indirect, pattern);
    }
    return pattern;
}
Also used : PDAbstractPattern(com.tom_roush.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSObject(com.tom_roush.pdfbox.cos.COSObject)

Aggregations

COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 COSObject (com.tom_roush.pdfbox.cos.COSObject)1 PDAbstractPattern (com.tom_roush.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern)1