def forge_stream(entries: dict, content: bytes) -> tuple:
    """Encode stream and calculate its length."""
    encoded = encode_stream(content, entries)
    envelope = Stream(entries, content, encoded)
    length = update_internal_stream_length(envelope)
    return envelope, length
Encode stream and calculate its length.
pdfsyntax/objects.py