Socket
Socket
Sign inDemoInstall

repo-to-pdf

Package Overview
Dependencies
48
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    repo-to-pdf

make pdf from a repo of source code


Version published
Maintainers
1
Created

Changelog

Source

v0.1.8(2023-08-01)

  • fix whitelist filtering
  • replace relaxedjs with raw puppeteer
  • add a pdf renderer wkhtmltopdf, faster but has split lines issue

Readme

Source

repo-to-pdf

npm npm

Make pdf from source code

Here is a sample

Install

npm install repo-to-pdf

Usage

Basic

npx repo-to-pdf [src/folder]
const {generateEbook} =  require('repo-to-pdf')

/**
 * @typedef Options
 * @type {object}
 * @property {string} renderer - [node|calibre|wkhtmltopdf] can be either node, calibre and wkhtmltopdf
 * @property {string} calibrePath - path of calibre's ebook-convert
 * @property {string} pdf_size - pdf size limit, in bytes
 * @property {string} white_list - list of file extensions to be included, separate by ','
 * @property {string} format - [mobi|epub|pdf] can be either mobi, epub, pdf
 * @property {string} device - [desktop|tablet|mobile] style can be opt for desktop, tablet and mobile
 * @property {string} baseUrl - base url of CSS style files
 */

/**
 * Generate ebook from content folder with the given file format
 * @param {string} inputFolder - content folder
 * @param {string} outputFile - output file name
 * @param {string} title - title in ebook file
 * @param {Options} options
 */
generateEbook(
  './',
  'test.pdf',
  'repo-test',
  {renderer:'node', pdf_size: 3*0.8*1000*1000, format: 'pdf', device: 'desktop'}
)

Command Line Options

-d, --device [platform]
device [desktop(default)|mobile|tablet]
# npx repo-to-pdf ../repo -d mobile

-t, --title [name]
pdf filename
# npx repo-to-pdf ../repo -t MeinKampf.pdf

-w, --whitelist [wlist]
file format white list, split by ","
# npx repo-to-pdf ../repo -w js,md

-s, --size [size]
pdf file size limit, in MB, default 10 MB
# npx repo-to-pdf ../repo -s 10

-r, --renderer [node|calibre|wkhtmltopdf]
use either node(relaxedjs) or calibre to render ebook, node outputs pdf, calibre outputs pdf, mobi, epub
# npx repo-to-pdf ../repo -r calibre

-f, --format [pdf|mobi|epub]
output format, either pdf, mobi, epub. mobi and epub are generated using calibre ebook-convert
# npx repo-to-pdf ../repo -f mobi

-c, --calibre [path]
path to ebook-convert, for MacOS, try /Applications/calibre.app/Contents/MacOS/ebook-convert; for linux, try /usr/bin/ebook-convert
For tablet, mobile

only supported by the renderer node

npx repo-to-pdf [src/folder] --device tablet
npx repo-to-pdf [src/folder] --device mobile

Testing

npm run test

Performance

on M1 Macbook Air

time npx repo-to-pdf ./test/data/redis-7.0.0/src -s 3
2.09s user 0.36s system 2% cpu 1:42.14 total

time npx repo-to-pdf ./test/data/redis-7.0.0/src -s 3 -r wkhtmltopdf
43.78s user 0.84s system 93% cpu 47.787 total

Known issues

Keywords

FAQs

Last updated on 01 Aug 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc