Skip to content

Export to pdf truncates code cells #9421

Description

@philipdeboer

Describe the bug

When I export a notebook to pdf from the command line (
uv run marimo export pdf
), the output includes the code cells as desired, but longer lines are truncated. Can we change the font size or margins during export to avoid this? Alternatively, perhaps the lines could be wrapped.

When I try to print to pdf from inside the Chrome browser, the code blocks don't print at all, which is unfortunate for my use case.

Separately, it would be nice if there was a way to expand all accordions so that I get a "full" printout. Generally, I seem to be looking for a way to reach under the hood and control the export functionality in more detail. If there's some section of the code that controls this, I'd be happy to poke around a little; I understand that rolling out a more flexible UI for general use could be a lot of work.

The background here is that I'm really enjoying marimo and finding that it gets us very close to self-documenting code. The pdf would be a way of archiving or distributing snapshots without environment dependence.

Will you submit a PR?

  • Yes

Environment

Details
{
  "marimo": "0.23.1",
  "editable": false,
  "location": "[ … ]/.venv/lib64/python3.12/site-packages/marimo",
  "OS": "Linux",
  "OS Version": "4.18.0-553.120.1.el8_10.x86_64",
  "Processor": "x86_64",
  "Python Version": "3.12.12",
  "Locale": "--",
  "Binaries": {
    "Browser": "--",
    "Node": "--",
    "uv": "0.11.7 (x86_64-unknown-linux-gnu)"
  },
  "Dependencies": {
    "click": "8.3.2",
    "docutils": "0.22.4",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.10.2",
    "narwhals": "2.19.0",
    "packaging": "26.1",
    "psutil": "7.2.2",
    "pygments": "2.20.0",
    "pymdown-extensions": "10.21.2",
    "pyyaml": "6.0.3",
    "starlette": "1.0.0",
    "tomlkit": "0.14.0",
    "typing-extensions": "4.15.0",
    "uvicorn": "0.44.0",
    "websockets": "16.0"
  },
  "Optional Dependencies": {
    "altair": "6.0.0",
    "loro": "1.10.3",
    "nbformat": "5.10.4",
    "pandas": "3.0.2",
    "polars": "1.39.3",
    "pyarrow": "24.0.0",
    "vegafusion": "2.0.3"
  },
  "Experimental Flags": {}
}

Code to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions