Skip to content

PDF

marimo.pdf

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

Render a PDF.

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

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

# from a local file
from pathlib import Path

mo.pdf(src=Path("paper.pdf"))
PARAMETER DESCRIPTION
src

the URL of the pdf, a file-like object, or a pathlib.Path object

TYPE: Path | str | IOBase

initial_page

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

TYPE: int | None DEFAULT: None

width

the width of the pdf

TYPE: int | str | None DEFAULT: '100%'

height

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

TYPE: int | str | None DEFAULT: '70vh'

style

a dictionary of CSS styles to apply to the pdf

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

RETURNS DESCRIPTION
Html

Html object