def serialize_fragment(num, o_gen, obj):
    """Build ascii block representing indirect object in file."""
    beginobj = f'{num} {o_gen}'.encode('ascii') + b' obj\n'
    ser = serialize(obj) + b'\n'
    endobj = b'endobj\n'
    block = beginobj + ser + endobj
    return block
Build ascii block representing indirect object in file.
pdfsyntax/filestruct.py