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.
- package/README.md +211 -98
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -1,98 +1,211 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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.
|
|
4
|
-
"description": "JavaScript SDK for the Dikshi Print Agent
|
|
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",
|