private TikaInputStream runFilters(COSBase filters, TikaInputStream is,
                                       List<COSName> usedFilters) throws IOException {
        if (filters instanceof COSNull) {
        } else if (filters instanceof COSName) {
            is = runFilter((COSName) filters, is, new COSDictionary(), 0);
            usedFilters.add((COSName) filters);
            LOG.debug("filter:" + filters + " " + 0 + " : " + is.getLength());
        } else if (filters instanceof COSArray) {
            COSArray filterArray = (COSArray) filters;
            //need to apply them in reverse order!
            boolean transformed = false;
            for (int i = filterArray.size() - 1; i >= 0; i--) {
                COSName filter = (COSName) filterArray.get(i);
                is = runFilter(filter, is, new COSDictionary(), 0);
                if (random.nextFloat() > 0.1 && transformed == false) {
                    is = transformRawStream(is);
                    transformed = true;
                }
                usedFilters.add(filter);
                LOG.debug("filter:" + filter.toString() + " " + i + " : " + is.getLength());
                if (is.getLength() > config.getMaxFilteredStreamLength()) {
                    LOG.debug("stopping early");
                    return is;
                }
            }
            return is;
        } else {
            throw new IllegalArgumentException(
                    "Can't handle this class here: " + filters.getClass());
        }
        return transformRawStream(is);
    }
This will write the body of the document.

@param doc The document to write the body for.
@throws IOException If there is an error writing the data.
tika-fuzzing/src/main/java/org/apache/tika/fuzzing/pdf/EvilCOSWriter.java