Skip to content

PDF

marimo.pdf

pdf(
    src: Union[str, IOBase],
    initial_page: Optional[int] = None,
    width: Optional[Union[int, str]] = "100%",
    height: Optional[Union[int, str]] = "70vh",
    style: Optional[dict[str, Any]] = None,
) -> Html

Render a PDF.

This currently uses the native browser PDF viewer, but may be replaced with a custom viewer.

Example
mo.pdf(
    src="https://arxiv.org/pdf/2104.00282.pdf",
    width="100%",
    height="50vh",
)

with open("paper.pdf", "rb") as file:
    mo.pdf(src=file)
PARAMETER DESCRIPTION
src

the URL of the pdf or a file-like object

TYPE: Union[str, IOBase]

initial_page

the page to open the pdf to. only works if src is a URL

TYPE: Optional[int] DEFAULT: None

width

the width of the pdf

TYPE: Optional[Union[int, str]] DEFAULT: '100%'

height

the height of the pdf. for a percentage of the user's viewport, use a string like "50vh"

TYPE: Optional[Union[int, str]] DEFAULT: '70vh'

style

a dictionary of CSS styles to apply to the pdf

TYPE: Optional[dict[str, Any]] DEFAULT: None

RETURNS DESCRIPTION
Html

Html object