List of usage examples for org.apache.pdfbox.cos COSArray getString
public String getString(int index)
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 }