ganeshh123 / notion-pdf-export

A tool to allow batch PDF export for free Notion users. You can export as HTML and then use this tool to convert those into PDFs.
https://app.gn3.sh/notion-pdf-export/
MIT License
427 stars 27 forks source link
batch batch-pdf-export export html nexe notion notion-pdf-export pdf pdf-generation wkhtmltopdf

Notion PDF Export

A tool to allow batch PDF export for free Notion users. You can export as HTML with subpages and then use this tool to convert those into PDFs.

Download

Get the latest download for Windows and macOS from the releases page:

https://github.com/ganeshh123/notion-pdf-export/releases

Download for Windows

Download for macOS

Usage

video guide

Video Guide

  1. Download the tool and extract. downloaded_program
  2. In Notion, place all the pages you wish to export into one page and click Export, choose 'HTML' and ensure 'Include Subpages' is on. notion-export
  3. Extract the export to find a list of HTML files and folders for each page. Place the HTML files with folders containing images in the same folder as notion-pdf-export.exe (Windows) or notion-pdf-export (macOS).
    placing-markdown-files
  4. Double click notion-pdf-export.exe (Windows) or notion-pdf-export (macOS) and wait for the process to be completed.
    running-program
    If nothing happens, you may need to go to macOS security settings and click 'Open Anyway':
    macOS_security
  5. All the individual pages can be found converted into PDF Documents inside the pdfs folder.
    created_pdfs

Building

Source Code

Running the Project on Node

  1. Clone/Download the project and run the command in the project root directory:
    npm install
  2. Run this command to run the script:
    node index.js

    Compiling an Executable

This is tricky. A lot of adjustments had to be made so that it can run without node.

Installing nexe

Executables are compiled with a very specific version of nexe that allows access to the filesystem, which has a tricky setup procedure.

To Install Automatically:
To Install Manually:
  1. Firstly, install the general nexe package globally:

    • Windows (in command prompt must be running as admin):
      npm install -g nexe
    • macOS (in the terminal):
      sudo npm install -g nexe
  2. In the project root folder build some executables with this version of nexe to download node binaries for Windows and macOS:

    nexe . --target win32-x86-10.13.0
    nexe . -t macos-10.13.0

    This will download the binaries we need for later, delete the executables built with this for now.

  3. Now we need to install a specific version of nexe that allows access to the filesystem:

    • Windows (in command prompt must be running as admin):
      npm install -g cspotcode/nexe#19a5046
    • macOS (in the terminal):
      sudo npm install -g cspotcode/nexe#19a5046

      Now we should have the correct version of nexe for building. Confirm by running:

    nexe -v

    Check that the version is 4.0.0-beta.4

Compiling Executables

Compile Automatically

If you wish to compile for macOS on Windows or vice versa, you can do so using the manual method below.

Compile Manually

Credits

wkhtmltopdf

This project uses wkhtmltopdf for the conversions. This brilliant tool was created by Jakob Truelsen and is now maintained by Ashish Kulkarni. Version 0.12.6 has been used, and can be downloaded here.

wkhtmltopdf is released under the LGPL-3.0 License which can be found at utils/wkhtmltopdf/LICENSE. The source code is available at the wkhtmltopdf repository.

Assets

Icon by Alex Martynov obtained from IconScout.