def apply_filter(doc: Doc, streams: list, flt: str = '/FlateDecode') -> Doc:
    """Force new filter state, for example /FlateDecode."""
    for o_num in streams:
        o = doc.obj(o_num)
        entries = o['entries']
        if '/Filter' in entries:
            if entries['/Filter'] == flt:
                continue
            else:
                for e in entries['/Filter'].split():
                    if e not in DECODED_FILTERS:
                        continue
        entries = deepcopy(entries)
        if '/Filter' in entries and flt == '':
            del entries['/Filter']
        else:
            entries['/Filter'] = flt
        s, length = forge_stream(entries, o['stream'])
        doc = update_object(doc, o_num, s)
    return doc
Force new filter state, for example /FlateDecode.
pdfsyntax/api.py