epub-to-pdf-cli 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # 📘 epub-to-pdf-cli
2
+
3
+ A simple and reliable **EPUB → PDF converter** using **Calibre**.
4
+ Works as both a **CLI tool** and a **Node.js library**.
5
+
6
+ ---
7
+
8
+ ## ✨ Features
9
+
10
+ - Convert EPUB to PDF using Calibre
11
+ - CLI and programmatic API
12
+ - Cross-platform (Linux, macOS, Windows)
13
+ - Lightweight, no bundled binaries
14
+ - Clear error messages
15
+
16
+ ---
17
+
18
+ ## 📦 Installation
19
+
20
+ ### Global install (CLI)
21
+
22
+ ```bash
23
+ npm install -g epub-to-pdf-cli
24
+ ```
25
+
26
+ ## Or run without installing
27
+ ```bash
28
+ npx epub-to-pdf-cli book.epub
29
+ ```
30
+
31
+ ## 🖥 CLI Usage
32
+ ```
33
+ epub2pdf <input.epub> [output.pdf]
34
+
35
+ Examples
36
+ epub2pdf mybook.epub
37
+ epub2pdf mybook.epub mybook.pdf
38
+ ```
39
+
40
+ ## 📚 Programmatic Usage
41
+ ### bash
42
+ ```bash
43
+ npm install epub-to-pdf-cli
44
+ ```
45
+ ### js
46
+ ```
47
+ import { convertEpubToPdf } from 'epub-to-pdf-cli';
48
+
49
+ await convertEpubToPdf('book.epub', 'book.pdf');
50
+ ```
51
+
52
+ ## ⚙ Requirements
53
+
54
+ This package requires Calibre to be installed.
55
+
56
+ Verify installation:
57
+ ### bash
58
+ ```
59
+ ebook-convert --version
60
+ ```
61
+ ## Install Calibre
62
+
63
+ ### Ubuntu/Debian
64
+ ```bash
65
+ sudo apt install calibre
66
+ ```
67
+ ### macOS
68
+ ``` bash
69
+ brew install calibre
70
+ ```
71
+ ### Windows
72
+ ``` bash
73
+ Download from: https://calibre-ebook.com/download
74
+ ```
75
+
76
+ ## ❌ Common Errors
77
+
78
+ ebook-convert not found
79
+ → Install Calibre and ensure it is in PATH.
80
+
81
+ ## 📄 License
82
+
83
+ MIT © Suraj Sutar
package/bin/cli.js CHANGED
@@ -1,29 +1,13 @@
1
- #!/usr/bin/env node
1
+ import { execSync } from 'child_process';
2
2
 
3
- import { convertEpubToPdf } from '../src/index.js';
3
+ try {
4
+ execSync('ebook-convert --version', { stdio: 'ignore' });
5
+ } catch {
6
+ console.error(`
7
+ ❌ Calibre is required.
4
8
 
5
- const args = process.argv.slice(2);
6
-
7
- if (args.length === 0) {
8
- console.log(`
9
- Usage:
10
- epub2pdf <input.epub> [output.pdf]
11
-
12
- Example:
13
- epub2pdf book.epub
14
- epub2pdf book.epub mybook.pdf
9
+ Install from:
10
+ https://calibre-ebook.com/download
15
11
  `);
16
12
  process.exit(1);
17
13
  }
18
-
19
- const input = args[0];
20
- const output = args[1];
21
-
22
- convertEpubToPdf(input, output)
23
- .then(out => {
24
- console.log(`✅ PDF created: ${out}`);
25
- })
26
- .catch(err => {
27
- console.error('❌ Conversion failed:', err.message);
28
- process.exit(1);
29
- });
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "epub-to-pdf-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Convert EPUB files to PDF using Calibre",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "epub2pdf": "./bin/cli.js"
9
9
  },
10
+ "scripts": {
11
+ "test": "node test.js",
12
+ "prepublishOnly": "node scripts/prepublish.js"
13
+ },
10
14
  "keywords": [
11
15
  "epub",
12
16
  "pdf",
@@ -0,0 +1,13 @@
1
+ import { execSync } from 'child_process';
2
+
3
+ try {
4
+ execSync('ebook-convert --version', { stdio: 'ignore' });
5
+ } catch {
6
+ console.error(`
7
+ ❌ Calibre is required but not installed.
8
+
9
+ Please install Calibre:
10
+ https://calibre-ebook.com/download
11
+ `);
12
+ process.exit(1);
13
+ }