Text wrapping in Notebook

I’ve been using Jupyter Notebook for some time, but after searching for some solutions, I am unable to get my text to wrap in code, and if I try saving it in a PDF, the code is cut off in some cells. Is there a way to fix this? I’m using the version 6.5.4.

I’m missing the context here? You first just mention using Jupyter Notebook (and presumably your title) and then are talking saving it as PDF. Those are two vastly different things. Where do you really need wrapping of code here?

Do you just need to view it ‘statically’ after-the-fact so the code isn’t cut off? (Like PDF) Then use nbviewer. See here for more about that with links to examples. If the content needs to be private you can use nbpreview, see more explanation about that at the top here.

A lot of these questions arise because there’s a lot of way to work in Jupyter with a lot of languages. Are you using Python? Then you can use black in conjunction with your notebook. You can just write and let it format later. This way your code is more portable in the end. See for example nbQA. Or see how with Jupytext you can pipe your notebook code to black here.

There’s lot of other options that make it hard to understand exactly what you seek at this point:

Code cell wrapping in Notebook help:

Code cell wrapping for Jupyter Notebook use in VSCode hlep:

Wrapping in JupyterLab help:

I’m attaching a picture to give you a visual of what I’m talking about. The code is written in Python. The text is still cut off when I change the destination to “Save as PDF”.

I’ll try the solutions you gave and see if something works out.

That screenshot looks to be like you are using the print ability of your browser to print to PDF? If that is the case, your browser has no idea about rendering .ipynb files. The information may be embedded in the PDF, but it doesn’t know to add scroll bars, etc… Or the data isn’t even there because it is just making a visual representation of the current screen. I’m not up on how that browser HTML to PDF works. However, …

If saving a notebook to PDF is what specifically you seek, then you need to use the ways built in to Jupyter to save your Notebook to PDF. And then see the result. There are two main ways, under ‘File’ > ‘Export’, you should have a way to export to PDF (Or possibly under ‘File’ > ‘Down’load’ (?), see the top sentence here.) Have you tried that? Then if you on the command line, you can use nbconvert, which is outlined here, with further advice for certain kinds of output and related items here, here, here, and here.