Skip to content

Commit b8ee8c4

Browse files
codebyterezcbenz
authored andcommitted
feat: enhance PrinterInfo object values (electron#21081)
1 parent 8320160 commit b8ee8c4

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

docs/api/structures/printer-info.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# PrinterInfo Object
22

3-
* `name` String
4-
* `description` String
5-
* `status` Number
6-
* `isDefault` Boolean
3+
* `name` String - the name of the printer as understood by the OS.
4+
* `displayName` String - the name of the printer as shown in Print Preview.
5+
* `description` String - a longer description of the printer's type.
6+
* `status` Number - the current status of the printer.
7+
* `isDefault` Boolean - whether or not a given printer is set as the default printer on the OS.
8+
* `options` Object - an object containing a variable number of platform-specific printer information.
9+
10+
The number represented by `status` means different things on different platforms: on Windows it's potential values can be found [here](https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-2), and on Linux and macOS they can be found [here](https://www.cups.org/doc/cupspm.html).
711

812
## Example
913

@@ -12,32 +16,34 @@ may be different on each platform.
1216

1317
```javascript
1418
{
15-
name: 'Zebra_LP2844',
16-
description: 'Zebra LP2844',
19+
name: 'Austin_4th_Floor_Printer___C02XK13BJHD4',
20+
displayName: 'Austin 4th Floor Printer @ C02XK13BJHD4',
21+
description: 'TOSHIBA ColorMFP',
1722
status: 3,
1823
isDefault: false,
1924
options: {
2025
copies: '1',
21-
'device-uri': 'usb://Zebra/LP2844?location=14200000',
26+
'device-uri': 'dnssd://Austin%204th%20Floor%20Printer%20%40%20C02XK13BJHD4._ipps._tcp.local./?uuid=71687f1e-1147-3274-6674-22de61b110bd',
2227
finishings: '3',
2328
'job-cancel-after': '10800',
2429
'job-hold-until': 'no-hold',
2530
'job-priority': '50',
2631
'job-sheets': 'none,none',
2732
'marker-change-time': '0',
2833
'number-up': '1',
29-
'printer-commands': 'none',
30-
'printer-info': 'Zebra LP2844',
34+
'printer-commands': 'ReportLevels,PrintSelfTestPage,com.toshiba.ColourProfiles.update,com.toshiba.EFiling.update,com.toshiba.EFiling.checkPassword',
35+
'printer-info': 'Austin 4th Floor Printer @ C02XK13BJHD4',
3136
'printer-is-accepting-jobs': 'true',
32-
'printer-is-shared': 'true',
37+
'printer-is-shared': 'false',
38+
'printer-is-temporary': 'false',
3339
'printer-location': '',
34-
'printer-make-and-model': 'Zebra EPL2 Label Printer',
40+
'printer-make-and-model': 'TOSHIBA ColorMFP',
3541
'printer-state': '3',
36-
'printer-state-change-time': '1484872644',
37-
'printer-state-reasons': 'offline-report',
38-
'printer-type': '36932',
39-
'printer-uri-supported': 'ipp://localhost/printers/Zebra_LP2844',
40-
system_driverinfo: 'Z'
42+
'printer-state-change-time': '1573472937',
43+
'printer-state-reasons': 'offline-report,com.toshiba.snmp.failed',
44+
'printer-type': '10531038',
45+
'printer-uri-supported': 'ipp://localhost/printers/Austin_4th_Floor_Printer___C02XK13BJHD4',
46+
system_driverinfo: 'T'
4147
}
4248
}
4349
```

shell/browser/api/atom_api_web_contents.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct Converter<printing::PrinterBasicInfo> {
131131
const printing::PrinterBasicInfo& val) {
132132
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
133133
dict.Set("name", val.printer_name);
134+
dict.Set("displayName", val.display_name);
134135
dict.Set("description", val.printer_description);
135136
dict.Set("status", val.printer_status);
136137
dict.Set("isDefault", val.is_default ? true : false);

0 commit comments

Comments
 (0)