Example usage for org.apache.pdfbox.cos COSArray getString

List of usage examples for org.apache.pdfbox.cos COSArray getString

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSArray getString.

Prototype

public String getString(int index) 

Source Link

Document

Get the value of the array as a string.

Usage

From source file:net.padaf.preflight.helpers.StreamValidationHelper.java

License:Apache License

/**
 * This method checks if one of declared Filter is LZWdecode. If LZW is found,
 * the result list is updated with an error code.
 * //from w  w  w  .java 2s  . co  m
 * @param stream
 * @param handler
 * @param result
 */
protected void checkFilters(COSStream stream, DocumentHandler handler, List<ValidationError> result) {
    COSDocument cDoc = handler.getDocument().getDocument();
    COSBase bFilter = stream.getItem(COSName.getPDFName(STREAM_DICTIONARY_KEY_FILTER));
    if (bFilter != null) {
        if (COSUtils.isArray(bFilter, cDoc)) {
            COSArray afName = (COSArray) bFilter;
            for (int i = 0; i < afName.size(); ++i) {
                if (!FilterHelper.isAuthorizedFilter(afName.getString(i), result)) {
                    return;
                }
            }
        } else if (bFilter instanceof COSName) {
            String fName = ((COSName) bFilter).getName();
            if (!FilterHelper.isAuthorizedFilter(fName, result)) {
                return;
            }
        } else {
            // ---- The filter type is invalid
            result.add(new ValidationError(ERROR_SYNTAX_STREAM_INVALID_FILTER,
                    "Filter should be a Name or an Array"));
        }
    }
    //  else Filter entry is optional
}