better-notion2pdf
v0.1.2
Published
Readable Notion-to-PDF builder with smart page breaks
Readme
better-notion2pdf
Readable Notion-to-PDF builder with smart page breaks.
Install
pnpm install
pnpm buildUsage
node dist/cli.js \
--url "https://www.notion.so/your-page" \
--out "portfolio.pdf" \
--profile portfolio \
--clean-level soft \
--code-wrap soft \
--code-font-size 11 \
--debug-shot "./debug/before.pdf.png" \
--debug-html "./debug/page.html"Key behavior
- Keeps content blocks (callout, quote, code, image, table)
- Removes Notion app chrome only (unless
--keep-ui) - Preserves original image quality (no re-encoding in pipeline)
- Uses smart page-break styles for headings and non-splittable blocks
Useful options
--cookie-file ./cookies.json: access private Notion pages with existing session cookies--code-wrap soft|hard|none: code block wrapping strategy in PDF--code-font-size 8..16: code block font size
Cookie file format example: examples/cookies.example.json
Debug outputs
When --debug-html is set, these files are also generated in the same folder:
page.html(current DOM)injected-css.cssbuild-log.json
Exit codes
0success10invalid input/options20timeout30auth/permission error40output write error50unknown internal error
Private Notion pages (cookie-file)
- Log in to Notion in Chrome.
- Open DevTools → Application → Cookies →
https://www.notion.so. - Export cookies and keep at least
name,value,domain(orurl). - Save as JSON like
examples/cookies.example.json. - Run with
--cookie-file ./cookies.json.
FAQ
Q. Why does private Notion fail?
- Use
--cookie-filewith a valid Notion session cookie and ensure page permission is granted.
Q. Are images compressed?
- No. This tool does not re-encode images. It only adjusts layout and page breaks.
Q. Why is Chrome sandbox error shown on Linux?
- In restricted Linux environments, Chromium sandbox may be unavailable. This tool launches with
--no-sandboxby default in this environment.
