Skip to content

Commit

Permalink
Merge pull request #13 from betatim/todo-for-v0.3
Browse files Browse the repository at this point in the history
Make no-sandbox the default for chromium
  • Loading branch information
betatim authored Jun 30, 2020
2 parents 3a5f6bc + 3c69e6a commit 2c53969
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ Three new features compared to the official "save as PDF" extension:

The created PDF will have as few pages as possible, in many cases only one. This is useful if you are exporting your notebook to a PDF for sharing with others who will view it on a screen.

To make it easier to reproduce the contents of the PDF at a later date the original notebook is attached to the PDF. Not all PDF viewers know how to deal with attachments. This mean you need to use Acrobat Reader or pdf.js to be able to get the attachment from the PDF. Preview for OSX does not know how to display/give you access to PDF attachments.
To make it easier to reproduce the contents of the PDF at a later date the original notebook is attached to the PDF. Unfortunately not all PDF viewers know how to deal with attachments. PDF viewers known to support downloading of file attachments are: Acrobat Reader, pdf.js and evince. The `pdftk` CLI program can also extract attached files from a PDF. Preview for OSX does not know how to display/give you access to attachments of PDF files.


## Install

To use this bundler you need to install it:
```
python -m pip install notebook-as-pdf
python -m pip install -U notebook-as-pdf
pyppeteer-install
```
The second command will download and setup Chromium. It is used to perform
the HTML to PDF conversion.

On linux you probably also need to install some or all of the APT packages
listed in [`binder/apt.txt`](binder/apt.txt).


## Use it

Expand Down
Binary file modified example.pdf
Binary file not shown.
13 changes: 5 additions & 8 deletions notebook_as_pdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ async def notebook_to_pdf(
config=None,
resources=None,
pyppeteer_args=None,
**kwargs):
**kwargs,
):
"""Convert a notebook to PDF"""
if config is None:
config = {}
Expand Down Expand Up @@ -131,13 +132,9 @@ class PDFExporter(Exporter):

export_from_notebook = "PDF via HTML"
output_mimetype = "application/pdf"
no_sandbox = Bool(
False,
help=(
"Whether to disable chrome sandboxing (not recommended, "
"but may be necessary if running as root)"
),
).tag(config=True)
no_sandbox = Bool(True, help=("Disable chrome sandboxing."),).tag(
config=True
)

@default("file_extension")
def _file_extension_default(self):
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
setup(
author="Tim Head",
author_email="[email protected]",
version="0.1.0",
version="0.3.0",
description="Jupyter extension to export notebooks as PDFs",
install_requires=["nbconvert", "pyppeteer", "PyPDF2"],
keywords="jupyter pdf export bundler",
Expand All @@ -21,5 +21,7 @@
packages=find_packages(),
python_requires=">=3.7",
url="https://github.com/betatim/notebook-as-pdf",
entry_points={"nbconvert.exporters": ["PDFviaHTML = notebook_as_pdf:PDFExporter"]},
entry_points={
"nbconvert.exporters": ["PDFviaHTML = notebook_as_pdf:PDFExporter"]
},
)

0 comments on commit 2c53969

Please sign in to comment.