Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf output with code #3415

Open
ggggggggg opened this issue Jan 13, 2025 · 5 comments
Open

pdf output with code #3415

ggggggggg opened this issue Jan 13, 2025 · 5 comments
Labels
enhancement New feature or request good first issue (typescript) Good first issue on the frontend/typescript help wanted Extra attention is needed

Comments

@ggggggggg
Copy link
Contributor

Description

I am hoping to be able to make pdf output with code, while using mo.mpl.interactive to display plots. Currently when I use the menu to do pdf output, it tells me to press Crtil+. to switch to app mode before making the pdf output. All my plots output fine, but the code is hidden.

Suggested solution

I can think of 2

  1. allow pdf output from notebook mode (I know there were correctness issues, so those would need to be fixed).
  2. allow app mode to show code, just not editable. (Is this already possible?)

Alternative

No response

Additional context

My use case is that I want a hard copy of "I did this analysis this way and got this result" that is immutable. I prefer pdf to html, as some features don't work in html output. Eg the "dataframe viewer" doesn't seem to work in html output since it no longer has access to the dataframe. I just want a copy of what was on the screen (and would have been if I scrolled) when I said to export a copy, and pdf seems best matched to that.

@ggggggggg ggggggggg added the enhancement New feature or request label Jan 13, 2025
@mscolnick
Copy link
Contributor

The current PDF output button in marimo programmatically calls print (Cmd+P). You could try that in the edit view.

Allow app mode to show code, just not editable

This is possible with marimo run nb.py --include-code

@ggggggggg
Copy link
Contributor Author

Thank you for the feedback! I did some more experimenting with pdf output, and tried some of your comments. This will be a bit of a grab bag of feedback. This is all on windows.

  1. marimo run nb.py --include-code Solution rating 6/10. brings up app view, and the code is not visible. There is a gui element in the top right that allows the code to be shown. But then there is no option to save as pdf, only as html and png.
  • Preferred usage: I switch to app mode without re-running the notebook from command line, have a gui element that allows showing code, and pdf output.
  • It's also confusing that "app mode" is different depending on how you get to it, though I do understand why you may disable switching back to edit mode when launched with marimo run.
  1. Try print directly through browser from edit mode. Solution rating 6/10. The margins are different, so text blocks that easily fit on screen and clipped. I tried charging the margins and didn't find a good setting that produced nice output.

Image

Marimo Env Output On windows. marimo env { "marimo": "0.10.12", "OS": "Windows", "OS Version": "10", "Processor": "Intel64 Family 6 Model 85 Stepping 4, GenuineIntel", "Python Version": "3.10.11", "Binaries": { "Browser": "131.0.6778.265", "Node": "--" }, "Dependencies": { "click": "8.1.7", "docutils": "0.20.1", "itsdangerous": "2.2.0", "jedi": "0.19.0", "markdown": "3.6", "narwhals": "1.22.0", "packaging": "23.1", "psutil": "5.9.5", "pygments": "2.16.1", "pymdown-extensions": "10.8.1", "pyyaml": "6.0.1", "ruff": "0.5.5", "starlette": "0.37.2", "tomlkit": "0.12.5", "typing-extensions": "4.7.1", "uvicorn": "0.30.1", "websockets": "12.0" }, "Optional Dependencies": { "altair": "5.3.0", "pandas": "2.1.0", "polars": "1.19.0", "pyarrow": "16.1.0" } }

@ggggggggg
Copy link
Contributor Author

ggggggggg commented Jan 15, 2025

Based on these tests would one of the following solutions be well aligned with other Marimo priorities?

  1. When in "app view", reached by using Ctrl+. to switch to from "edit view" add a method to Show Code.
  2. When in "edit view" allow pdf output with margins such that a typical marimo cell fits on a page.

@mscolnick
Copy link
Contributor

  1. When in "edit view" allow pdf output with margins such that a typical marimo cell fits on a page.

This sounds better to me. We have some existing CSS to handle @media print {, which we can improve so Cmd+p (print) works better out of the box

@ggggggggg
Copy link
Contributor Author

I like that idea, I'm hoping it comes online soon so I can let my colleagues print out copies of their finished notebooks. Thanks.

@mscolnick mscolnick added help wanted Extra attention is needed good first issue (typescript) Good first issue on the frontend/typescript labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue (typescript) Good first issue on the frontend/typescript help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants