def update_version(doc: Doc, ver: str) -> Doc:
    """Upgrade PDF version in incremental update."""
    cat, i_ref = catalog(doc)
    if '/Version' in cat:
        if cat['/Version'][1:] < ver:
            cat['/Version'] = '/' + ver
            return update_object(doc, int(i_ref.imag), cat)
        else:
            return doc
    else:
        cat['/Version'] = '/' + ver
        return update_object(doc, int(i_ref.imag), cat)
Upgrade PDF version in incremental update.
pdfsyntax/docstruct.py