-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
829 additions
and
53 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,69 @@ | ||
# Download Jupyter Notebook as a PDF | ||
|
||
Downloading Jupyter Notebooks (.ipynb files) as PDF can be slightly confusing given the numebr of options presented in the notebook UI. [nbconvert](https://github.com/jupyter/nbconvert) is the third-party package used to convert notebook files (ipynb) to file formats such PDF,HTML, PNG etc...The options to download notebook as PDF/HTML has changed recently due to the migration from notebook 6 to 7 and Lab 3 to 4. | ||
Downloading Jupyter Notebooks (.ipynb files) as PDF can be slightly confusing given the number of options presented in the notebook UI. [nbconvert](https://github.com/jupyter/nbconvert) is the third-party package used to convert notebook files (ipynb) to file formats such PDF,HTML, PNG etc...The options to download notebook as PDF/HTML has changed recently due to the migration from notebook 6 to 7 and Lab 3 to 4. | ||
|
||
If you are using https://datahub.berkeley.edu/ and/or https://r.datahub.berkeley.edu/, then choose the following option to download the ipynb as pdf, | ||
Choose the following option to download the ipynb file(s) as pdf then choose the following option, | ||
|
||
File -> Save and Export Notebook As -> Webpdf | ||
|
||
```{figure} ../images/download_webPDF.png | ||
```{figure} ../images/download_notebook_webpdf.png | ||
:width: 500px | ||
:align: center | ||
:name: Download Jupyter Notebook as Web PDF | ||
``` | ||
|
||
```{note} | ||
When using webpdf option, ensure that your images are formatted appropriately so that it gets rendered in the PDF given the issue with [nbconvert](https://github.com/jupyter/nbconvert/issues/1326#issuecomment-1019204102). | ||
If you choose to download the ipynb file(s) as HTML then choose the following option, | ||
|
||
File -> Save and Export Notebook As -> HTML | ||
|
||
Absolute URLs: Images with absolute URLs in the image tag source are rendered in the PDF. Example: <img src="https://data-88e.github.io/assets/images/blue_text.png">. | ||
```{figure} ../images/download_notebook_html.png | ||
:width: 500px | ||
:align: center | ||
:name: Download Jupyter Notebook as HTML | ||
``` | ||
|
||
Relative URLs: Images with relative URLs in the image tag source won't be rendered in the PDF. Example: <img src="blue_text.png">. | ||
```{note} | ||
When it comes to embedding images in Jupyter notebooks so that it is available as part of PDF, there are various methods to include images. Below are the five options to embed an image of an early Mathematica interface. | ||
Markdown Format: Images added in Markdown format, like | ||
#### HTML Image Tag | ||
```{code} | ||
![Macss Logo](blue_text.png) | ||
<img src="mathematica.png" alt="Early Mathematica Interface" style="width: 250px;" class="center"/> | ||
``` | ||
,are rendered in the PDF. | ||
|
||
``` | ||
This method uses standard HTML to embed an image. It is straightforward and allows for extensive customization through HTML attributes like style and class. | ||
|
||
If you are using any other hub than the ones mentioned above, choose the following option, | ||
File -> Save and Export Notebook As -> PDF | ||
#### Markdown Image Syntax | ||
|
||
```{figure} ../images/download_PDF.png | ||
:width: 500px | ||
:align: center | ||
:name: Download Jupyter Notebook as PDF | ||
```{code} | ||
![mathematica](mathematica.png) | ||
``` | ||
|
||
If you choose to download the notebook files as HTML then choose the following option, | ||
File -> Save and Export Notebook As -> HTML | ||
Markdown provides a simple syntax for embedding images. This method is concise and ideal for use in Markdown cells in Jupyter notebooks. | ||
|
||
```{figure} ../images/download_HTML.png | ||
:width: 500px | ||
:align: center | ||
:name: Download Jupyter Notebook as HTML | ||
``` | ||
#### HTML in Markdown Cell | ||
|
||
```{code} | ||
<img src="https://rtl.berkeley.edu/profiles/openberkeley/themes/openberkeley_theme_brand/assets/images/berkeley_wordmark_blue_175x70.svg" alt="Berkeley Logo" style="width: 250px;" class="center"/> | ||
``` | ||
|
||
Embedding an image using HTML within a Markdown cell offers the flexibility of HTML while allowing the cell to remain in Markdown mode. This is useful for more complex styling and alignment requirements. | ||
|
||
#### IPython Display Module | ||
|
||
```{code} | ||
from IPython.display import display, Image | ||
display(Image(filename="mathematica.png", width=250))\ | ||
``` | ||
|
||
The IPython.display module provides functions to display images directly in Jupyter notebooks. | ||
|
||
#### Markdown Image with Attachment | ||
|
||
```{code} | ||
![mathematica.png](attachment:5265a161-c705-42fc-a3ed-ec1fde427030.png) | ||
``` | ||
|
||
This method is used to embed an image as an attachment within a Jupyter notebook. It references the image by its attachment identifier, which is useful for images embedded directly within the notebook file. | ||
|
||
```{note} | ||
We recommend instructors/students to not use the "File -> Save and Export Notebook as -> Latex" option as it has historically led to "500 internal server error"message for some of our users (like [this](https://github.com/berkeley-dsep-infra/datahub/issues/2664)). | ||
``` |
Oops, something went wrong.