cli-pdf-generator 0.0.1 → 0.0.3

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,98 @@
1
+ # cli-pdf-generator
2
+
3
+ Generate PDF files from JSON payloads using a local CLI.
4
+
5
+ `cli-pdf-generator` uses:
6
+
7
+ - **Oclif** for the command-line interface
8
+ - **Handlebars** for HTML templates
9
+ - **Playwright** to render the final PDF with headless Chromium
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install -g cli-pdf-generator
15
+ ```
16
+
17
+ The package installs Playwright Chromium during installation. The first install may take a little longer.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ pdfgen generate --input payload.json --output invoice.pdf
23
+ ```
24
+
25
+ ## Example Payload
26
+
27
+ ```json
28
+ {
29
+ "template": "invoice",
30
+ "filename": "sample_invoice.pdf",
31
+ "data": {
32
+ "company": {
33
+ "name": "Sample Company"
34
+ },
35
+ "party": {
36
+ "name": "Sample Customer"
37
+ },
38
+ "invoice_no": "INV-001",
39
+ "date": "01-01-2026",
40
+ "items": [
41
+ {
42
+ "description": "Sample Product",
43
+ "hsn": "00000000",
44
+ "qty": "1 Unit",
45
+ "rate": "1000.00/Unit",
46
+ "taxable": "1000.00",
47
+ "tax": "18%",
48
+ "total": "1180.00"
49
+ }
50
+ ],
51
+ "totals": {
52
+ "taxable": "1000.00",
53
+ "tax": "180.00",
54
+ "grand_total": "1180.00"
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Templates
61
+
62
+ Supported templates:
63
+
64
+ - `invoice`
65
+ - `generic`
66
+
67
+ Use the `template` field in your payload to select the template.
68
+
69
+ ## How It Works
70
+
71
+ ```text
72
+ JSON payload
73
+ -> Oclif CLI command
74
+ -> Handlebars HTML template
75
+ -> Playwright Chromium PDF render
76
+ -> PDF file
77
+ ```
78
+
79
+ The CLI only writes the final PDF file. HTML rendering is internal.
80
+
81
+ ## Local Development
82
+
83
+ ```bash
84
+ npm install
85
+ npm run check
86
+ npm run generate -- --input payload.example.json --output sample_invoice.pdf
87
+ ```
88
+
89
+ ## Command
90
+
91
+ ```bash
92
+ pdfgen generate --input <payload.json> --output <output.pdf>
93
+ ```
94
+
95
+ Options:
96
+
97
+ - `--input`, `-i`: path to the JSON payload file
98
+ - `--output`, `-o`: output PDF path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-pdf-generator",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Generate PDFs from JSON data using CLI templates.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,15 +14,20 @@
14
14
  {
15
15
  "description": "Sample Product",
16
16
  "hsn": "00000000",
17
- "qty": "1 Unit",
18
- "rate": "1000.00/Unit",
17
+ "qty": "10 pieces",
18
+ "rate": "100.00/piece",
19
19
  "taxable": "1000.00",
20
20
  "tax": "18%",
21
- "total": "1180.00"
21
+ "total": "1000.00"
22
22
  }
23
23
  ],
24
24
  "totals": {
25
25
  "taxable": "1000.00",
26
+ "cgst_rate": "9%",
27
+ "cgst": "90.00",
28
+ "sgst_rate": "9%",
29
+ "sgst": "90.00",
30
+ "round_off": "0.00",
26
31
  "tax": "180.00",
27
32
  "grand_total": "1180.00"
28
33
  }