Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@subhamx/notion-to-ebook

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@subhamx/notion-to-ebook

Notion to ebook is a lightweight library to convert notion document consisting of multiple nested documents or databases into an ebook format like PDFs, with the table of contents, page cover, headers etc.

  • 1.0.0
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Notion to Ebook

Apache-2.0 NPM Package Link

Notion to Ebook is a lightweight library written in Typescript to convert any notion document consisting of multiple nested documents or databases into an ebook format like PDFs, with the table of contents, page cover, headers etc.

Use Cases

  1. Say you have a notion database containing many documents, and you wish to export them into a single PDF. Notion doesn't allow non-enterprise uses to include all the subpages into a single PDF recursively (Have a look at image below). But this library lets you generate it without any hassle, and even on a free plan. :) PDF Export Dialog
  2. Say you have an e-reader like Kindle would like to send all the articles you have written on Notion workspace every 24 hours automatically. Notion to Ebook can help you in it. You can use it to get the Ebook version, then can send it to your e-reader device. :). You may consider using GitHub actions or any similar service to automate the workflow.

Features

This application requires Zero Configuration. The current implementation does most things like arranging all the files as chapters and generating the Table of Contents, cover page, footer, etc.

There are two modes to use this application:

  1. Standalone mode: It allows users to generate a separate PDF for each of the HTML pages. For example, if your notion exports have a total of 12 pages (including all nested docs, tables etc.), then there will be precisely 12 PDFs generated for each one of them. You can find the exported merged file inside session_files/output/merged.

  2. Merge mode: It allows users to generate a single PDF for the entire export. It concatenates each of the notion pages smartly to generate a single document. Table of contents of the whole document is also included at the beginning to ease browsing across the different sections of the merged PDF. You can find the exported standalone files inside session_files/output/standalone.

Please note that in merge mode all documents not linking to any other document at the current level are placed before the documents linking to other ones.

Installation

npm install @subhamx/notion-to-ebook

API

The usage is pretty straightforward.

  1. If you want to use in the standalone mode and generate separate PDF document for each one Notion Page.
import { buildStandaloneDocs } from '@subhamx/notion-to-ebook';

const token_v2="YOUR_NOTION_TOKEN_V2";
const pageId= "NOTION_PAGE_ID";

buildStandaloneDocs(token_v2, pageId);
  1. If you want to use in the merged mode and generate a single PDF document for each the complete export.
import { buildMergedDoc } from '@subhamx/notion-to-ebook';

const token_v2="YOUR_NOTION_TOKEN_V2";
const pageId= "NOTION_PAGE_ID";

buildMergedDoc(token_v2, pageId);

Note: Whenever you call any of the instances of buildStandaloneDocs or buildMergedDoc. It removes all files inside the session_files. So please be cautious before starting the script.

Example

We will export this Notion document, which is a full-page database and has four documents inside it.

Please note that Notion doesn't allow us to export all of these documents as PDFs in one go without the enterprise plan.

  1. Standalone files: Link
  2. Merged file: Link

It's Great, isn't it? 🎉

Future Changes in API

  1. Currently, the only export format this library supports is PDF. We plan to add additional formats like LaTex, mobi, epub etc. very soon.
  2. More support to tweak the configuration.

Contributing

This project welcomes contributions and suggestions. Feel free to report bugs and suggest features. It will help us improve this project. ⚡⚡

Keywords

FAQs

Package last updated on 04 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc