googlecolab / colabtools

Python libraries for Google Colaboratory
Apache License 2.0
2.21k stars 724 forks source link

Print > Save as PDF has code cells overlapping with output from other cells (e.g. charts and dataframes) #4005

Open meganlubow opened 1 year ago

meganlubow commented 1 year ago

Describe the current behavior Print > Save as PDF has code cells overlapping with output from other cells (e.g. charts and dataframes) which is causing parts of my charts/dataframes to not be visible in the PDF. See page 40 of the attached file v2+-+DSO560_assignment_2_Megan_Lubow.ipynb+-+Colaboratory.pdf for the chart that is cut off and page 41 for the dataframe that is cut off.

Describe the expected behavior I would expect none of the code/charts/dataframes/visualizations to overlap with each other. They don't overlap in the colab UI, so why are the overlapping and cutting each other off in the PDF?

What web browser you are using Chrome

Additional context https://colab.research.google.com/drive/1gOu-NrAuwhXhknauMn1VLOpm_KzZQMye?usp=sharing

tnahata commented 1 year ago

As a quick workaround, I just added blank lines after my plt.show() or any other plot/chart so that the plot/chart gets displayed properly before the code or text after gets printed.

jonathanagustin commented 12 months ago

@meganlubow

This may not be what you are looking for, but I created a code snippet that turns Colab notebooks into PDFs (no configuration necessary - just copy, paste, and run).

I imagine you can run the code snippet to download the notebook as a PDF and then print it.

https://github.com/drengskapur/colab2pdf