dikshiprintagent 1.0.1 → 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.
Files changed (2) hide show
  1. package/README.md +211 -98
  2. package/package.json +8 -2
package/README.md CHANGED
@@ -1,98 +1,211 @@
1
- # Dikshi Print Agent V10
2
-
3
- Windows local print bridge for websites. Designed around Windows printer queues, so newly installed printers are discovered automatically when Windows has a working driver.
4
-
5
- Android/iOS remote printing through the optional secure relay is documented in [REMOTE-PRINTING.md](REMOTE-PRINTING.md).
6
-
7
- ## V10 features
8
- - Windows tray application
9
- - Loopback-only HTTP API on `127.0.0.1:8181`
10
- - First-run 256-bit random API token
11
- - Origin allow-list/CORS protection
12
- - Dynamic installed-printer discovery and default-printer detection
13
- - Queued print jobs + job status/history
14
- - Text printing through Windows PrintDocument
15
- - Image printing (base64 PNG/JPG/BMP etc.)
16
- - RAW printing through Winspool (label languages / printer-native data)
17
- - ESC/POS uses the RAW path
18
- - PDF printing through Windows registered PDF `printto` handler
19
- - Direct PDF URL printing: agent downloads the PDF from an API URL and sends it to the selected printer
20
- - HTML printing through WebView2 with page size/orientation options
21
- - Invoice/receipt template printing from plain JSON data
22
- - QR and CODE128 barcode printing
23
- - ESC/POS receipt builder in the browser SDK
24
- - Persistent recent job history under `%APPDATA%\DikshiPrintAgent\job-history.json`
25
- - Local dashboard with printer list, HTML/text test print, and job history
26
- - Visual template designer at `/designer` with drag/drop fields and saved JSON layouts
27
- - Designer validation, version backups, locked layouts, resize handles, undo/redo, zoom, logo upload, and custom table columns
28
- - Dashboard/designer pages do not embed the API token; paste it from the tray menu before using protected actions
29
- - Daily logs under `%APPDATA%\DikshiPrintAgent\logs`
30
- - Start-with-Windows support
31
- - Browser JavaScript SDK + test page
32
- - Single-file self-contained `win-x64` publish
33
- - Inno Setup script included
34
-
35
- ## Build
36
- Install the Microsoft .NET 8 SDK on the Windows development PC, then run `build-exe.bat`.
37
- Output: `DikshiPrintAgent-V10.exe` in the project root.
38
-
39
- ## First run
40
- Run the EXE. It creates:
41
- `%APPDATA%\DikshiPrintAgent\config.json`
42
-
43
- Right-click the tray icon -> **Copy API Token**.
44
- Edit `AllowedOrigins` in config.json to include your websites, then restart the agent.
45
- Example:
46
- ```json
47
- "AllowedOrigins": [
48
- "https://erp.example.com",
49
- "https://billing.example.com",
50
- "http://localhost:*"
51
- ]
52
- ```
53
- Do not set `AllowAllOrigins=true` on production PCs unless you fully understand the security risk.
54
-
55
- ## API
56
- - `GET /api/v1/health` (no token; health only)
57
- - `GET /api/v1/printers`
58
- - `GET /api/v1/jobs`
59
- - `GET /api/v1/jobs/{id}`
60
- - `GET /api/v1/templates`
61
- - `GET /api/v1/templates/{name}`
62
- - `POST /api/v1/templates`
63
- - `POST /api/v1/print/text`
64
- - `POST /api/v1/print/image`
65
- - `POST /api/v1/print/code`
66
- - `POST /api/v1/print/raw`
67
- - `POST /api/v1/print/escpos`
68
- - `POST /api/v1/print/pdf`
69
- - `POST /api/v1/print/pdf-url`
70
- - `POST /api/v1/print/html`
71
- - `POST /api/v1/print/template`
72
- - `POST /api/v1/print/designed-template`
73
- - WebSocket: `/ws?token=...`
74
-
75
- Authenticated REST requests require `X-Dikshi-Token`.
76
-
77
- ### Print a PDF directly from an API URL
78
- Use this when your server API returns `application/pdf` as a downloadable file. The agent downloads the PDF locally, validates it, queues it, and prints through the existing PDF print handler.
79
-
80
- ```bash
81
- curl -X POST "http://127.0.0.1:8181/api/v1/print/pdf-url" \
82
- -H "Content-Type: application/json" \
83
- -H "X-Dikshi-Token: YOUR_AGENT_TOKEN" \
84
- -d "{\"printer\":\"YOUR_WINDOWS_PRINTER_NAME\",\"url\":\"https://dikshitech.ddns.net/kingmotorsapi/api/BookingEntry/DownloadBookingPdf/001/B00009AA\",\"documentName\":\"Booking_B00009AA.pdf\"}"
85
- ```
86
-
87
- Browser SDK:
88
- ```js
89
- await agent.printPdfUrl(printerName, bookingPdfUrl, {
90
- documentName: 'Booking_B00009AA.pdf'
91
- });
92
- ```
93
-
94
- ## Important compatibility notes
95
- 1. Generic printing works with printers exposed as valid Windows printer queues. Future printer models normally need only their Windows driver.
96
- 2. RAW/ESC-POS requires the printer/driver to accept the command language being sent. There is no universal ESC/POS guarantee for every model.
97
- 3. PDF `printto` relies on a Windows PDF application that implements the `printto` shell verb. For maximum unattended PDF reliability, a dedicated PDF rendering/printing engine should be embedded in a future signed enterprise build.
98
- 4. An HTTPS website talking to a local agent can be affected by browser mixed-content/private-network policies. For strict enterprise/all-site deployment, use a trusted local TLS certificate or companion Chrome/Edge extension. This source keeps loopback HTTP intentionally simple and auditable.
1
+ # dikshiprintagent
2
+
3
+ Official JavaScript SDK for connecting a website, billing application, POS, ERP, or web portal to **Dikshi Print Agent** running on a Windows computer.
4
+
5
+ It lets a web application discover installed Windows printers and submit text, HTML, image, PDF, barcode, QR-code, RAW, and ESC/POS print jobs through a simple JavaScript API.
6
+
7
+ > This npm package is the web SDK. The Dikshi Print Agent Windows application must be installed and running on every computer that needs to print.
8
+
9
+ ## How it works
10
+
11
+ ```text
12
+ Website / Billing App
13
+ | dikshiprintagent npm SDK
14
+ v
15
+ http://127.0.0.1:8181
16
+ v
17
+ Dikshi Print Agent for Windows
18
+ v
19
+ Installed Windows Printer
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install dikshiprintagent
26
+ ```
27
+
28
+ The SDK uses ES modules and supports modern browser build tools such as Vite, React, Vue, Angular, and Next.js client components.
29
+
30
+ ## Before you start
31
+
32
+ On the Windows billing computer:
33
+
34
+ 1. Install and run Dikshi Print Agent.
35
+ 2. Confirm that the required printer is installed in Windows.
36
+ 3. Right-click the agent tray icon and select **Copy API Token**.
37
+ 4. Add your website origin to `%APPDATA%\DikshiPrintAgent\config.json`.
38
+ 5. Restart the agent after changing its configuration.
39
+
40
+ ```json
41
+ {
42
+ "port": 8181,
43
+ "allowAllOrigins": false,
44
+ "allowedOrigins": [
45
+ "http://localhost:5173",
46
+ "http://localhost:3000",
47
+ "https://your-website.example"
48
+ ]
49
+ }
50
+ ```
51
+
52
+ Never publish or hard-code a customer's API token in source control.
53
+
54
+ ## Quick start
55
+
56
+ ```js
57
+ import DikshiPrintAgent from 'dikshiprintagent';
58
+
59
+ const agent = new DikshiPrintAgent({
60
+ token: 'TOKEN_COPIED_FROM_THE_WINDOWS_TRAY_APP'
61
+ });
62
+
63
+ const health = await agent.health();
64
+ console.log('Agent:', health);
65
+
66
+ const result = await agent.printers();
67
+ console.log('Printers:', result.printers);
68
+
69
+ const job = await agent.printText(result.printers[0].name, 'Hello from Dikshi!');
70
+ const completedJob = await agent.wait(job.jobId, 30000);
71
+ console.log('Completed:', completedJob);
72
+ ```
73
+
74
+ ## Constructor
75
+
76
+ ```js
77
+ const agent = new DikshiPrintAgent({
78
+ token: 'required-api-token',
79
+ host: '127.0.0.1', // optional
80
+ port: 8181, // optional
81
+ protocol: 'http' // optional: http or https
82
+ });
83
+ ```
84
+
85
+ ## Common examples
86
+
87
+ ### Print text
88
+
89
+ ```js
90
+ const job = await agent.printText('EPSON TM-T82', 'Thank you!', {
91
+ documentName: 'Receipt 1001',
92
+ fontName: 'Consolas',
93
+ fontSize: 10,
94
+ copies: 1
95
+ });
96
+ await agent.wait(job.jobId);
97
+ ```
98
+
99
+ ### Print HTML or PDF URL
100
+
101
+ ```js
102
+ await agent.printHtml('Invoice Printer', '<h1>Invoice #1001</h1>', {
103
+ documentName: 'Invoice 1001'
104
+ });
105
+
106
+ const job = await agent.printPdfUrl('HP Laser Printer', invoiceUrl, {
107
+ documentName: 'Invoice 1001.pdf'
108
+ });
109
+ await agent.wait(job.jobId, 30000);
110
+ ```
111
+
112
+ ### QR code and barcode
113
+
114
+ ```js
115
+ await agent.printQr('Label Printer', 'https://www.dikshitech.com/');
116
+ await agent.printBarcode('Label Printer', 'ITEM-10001');
117
+ ```
118
+
119
+ ### ESC/POS receipt
120
+
121
+ ```js
122
+ const receipt = DikshiPrintAgent.receiptBuilder({ width: 42 })
123
+ .center().bold().text('DIKSHI STORE\n').bold(false)
124
+ .line()
125
+ .row('Invoice', 'INV-1001')
126
+ .item('Product', 2, 100)
127
+ .line()
128
+ .row('Total', 'Rs. 200.00')
129
+ .cut()
130
+ .build();
131
+
132
+ const job = await agent.printEscPos('Thermal Printer', receipt);
133
+ await agent.wait(job.jobId);
134
+ ```
135
+
136
+ RAW and ESC/POS printing require a printer and Windows driver that accept the commands being sent.
137
+
138
+ ## SDK methods
139
+
140
+ | Method | Purpose |
141
+ | --- | --- |
142
+ | `health()` | Check whether the local agent is running |
143
+ | `printers()` | Get installed Windows printers |
144
+ | `jobs()` / `job(jobId)` | Read recent jobs or one job |
145
+ | `wait(jobId, timeoutMs)` | Wait until a job completes or fails |
146
+ | `printText()` / `printHtml()` | Print text or HTML |
147
+ | `printImage()` | Print a base64 image |
148
+ | `printPdf()` / `printPdfUrl()` | Print a base64 PDF or PDF URL |
149
+ | `printQr()` / `printBarcode()` | Print QR and CODE128 codes |
150
+ | `printRaw()` / `printEscPos()` | Send printer-native data |
151
+ | `templates()` / `template(name)` | Read saved templates |
152
+ | `saveTemplate()` | Save a print template |
153
+ | `printTemplate()` | Print template data |
154
+ | `printDesignedTemplate()` | Print a designer template |
155
+
156
+ TypeScript declarations are included.
157
+
158
+ ## Troubleshooting
159
+
160
+ - **Token is required:** Copy it from the Windows tray application and pass it to the constructor.
161
+ - **Connection failed:** Open `http://127.0.0.1:8181/api/v1/health`. Start or restart the agent if it does not return JSON.
162
+ - **HTTP 401:** The token is missing or incorrect. Copy the current token again.
163
+ - **CORS/origin error:** Add the exact origin, such as `http://localhost:5173`, to `allowedOrigins` and restart the agent.
164
+ - **HTTPS to local HTTP blocked:** Some browsers and enterprise policies require trusted local HTTPS or approved browser configuration.
165
+ - **Printer missing:** Install its Windows driver, confirm it appears in Windows Printers & scanners, and reload the list.
166
+
167
+ ## Security
168
+
169
+ - Keep `allowAllOrigins` disabled in production.
170
+ - Allow only trusted application origins.
171
+ - Never store a real agent token in a public repository.
172
+ - Store the token locally per billing computer or user.
173
+ - The default service listens on loopback address `127.0.0.1`.
174
+
175
+ ## About Dikshi Technologies
176
+
177
+ **Dikshi Technologies** is a Chennai-based software and digital-solutions company with its office in Pallikaranai. With over 22 years of domain experience, the company develops practical ERP, billing, mobile, RFID, and automation solutions for retail and service businesses.
178
+
179
+ ### Products and services
180
+
181
+ - Jewellery billing, POS, stock, order, customer, and ERP solutions
182
+ - Jewellery RFID inventory, auditing, tracking, and loss-prevention solutions
183
+ - **Pawn Pro** for pawn-broking and pledge-management operations
184
+ - Wholesale, retail, supermarket, and hypermarket billing software
185
+ - Textile, readymade, garment, and footwear ERP software
186
+ - Restaurant, hotel, hardware, fancy-store, and industry-specific billing systems
187
+ - Barcode, QR-code, tag, label, and thermal-printing integrations
188
+ - Windows, web, Android, iOS, cloud, and multi-branch applications
189
+ - Custom ERP, CRM, business automation, and software development
190
+ - Website and mobile-application development
191
+ - Social-media marketing, digital marketing, SEO, content, creative, and other digital services
192
+
193
+ ### Office and contact
194
+
195
+ ```text
196
+ Dikshi Technologies
197
+ No. 80 & 81, Devi Karumariamman Nagar
198
+ Velachery Main Road, Near Oil Mill Bus Stop
199
+ Pallikaranai, Chennai – 600100
200
+ Tamil Nadu, India
201
+ ```
202
+
203
+ - Website: [www.dikshitech.com](https://www.dikshitech.com/)
204
+ - Email: [dikshitechnologies@gmail.com](mailto:dikshitechnologies@gmail.com)
205
+ - Phone: [+91 98414 19981](tel:+919841419981)
206
+ - Demo / WhatsApp: [+91 74488 80373](tel:+917448880373)
207
+ - LinkedIn: [Dikshi Technologies](https://www.linkedin.com/company/dikshitech/)
208
+
209
+ ## License
210
+
211
+ [MIT](LICENSE) © 2026 Dikshi Technologies.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dikshiprintagent",
3
- "version": "1.0.1",
4
- "description": "JavaScript SDK for the Dikshi Print Agent local Windows printing service",
3
+ "version": "1.0.2",
4
+ "description": "JavaScript SDK for silent printing from web applications through the Dikshi Print Agent for Windows",
5
5
  "keywords": [
6
6
  "printing",
7
7
  "silent-print",
@@ -10,6 +10,12 @@
10
10
  "dikshi"
11
11
  ],
12
12
  "license": "MIT",
13
+ "author": {
14
+ "name": "Dikshi Technologies",
15
+ "email": "dikshitechnologies@gmail.com",
16
+ "url": "https://www.dikshitech.com/"
17
+ },
18
+ "homepage": "https://www.dikshitech.com/",
13
19
  "type": "module",
14
20
  "main": "./npm/index.js",
15
21
  "module": "./npm/index.js",