def draw_replacedbox(stream, box):
    """Draw the given :class:`boxes.ReplacedBox` to a ``pdf.stream.Stream``."""
    if box.style['visibility'] != 'visible' or not box.width or not box.height:
        return

    draw_width, draw_height, draw_x, draw_y = replaced.replacedbox_layout(box)
    if draw_width <= 0 or draw_height <= 0:
        return

    with stacked(stream):
        stream.set_alpha(1)
        stream.transform(e=draw_x, f=draw_y)
        with stacked(stream):
            # TODO: Use the real intrinsic size here, not affected by
            # 'image-resolution'?
            box.replacement.draw(
                stream, draw_width, draw_height, box.style['image_rendering'])
Draw the given :class:`boxes.ReplacedBox` to a ``pdf.stream.Stream``.
weasyprint/draw/__init__.py