printerList() -> getPrinters()
This commit is contained in:
parent
84a9b6a42d
commit
92f14f8d52
3 changed files with 39 additions and 37 deletions
|
@ -143,9 +143,9 @@ struct Converter<printing::PrinterBasicInfo> {
|
||||||
static v8::Local<v8::Value>
|
static v8::Local<v8::Value>
|
||||||
ToV8(v8::Isolate* isolate, const printing::PrinterBasicInfo& val) {
|
ToV8(v8::Isolate* isolate, const printing::PrinterBasicInfo& val) {
|
||||||
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||||
dict.Set("printerName", val.printer_name);
|
dict.Set("name", val.printer_name);
|
||||||
dict.Set("printerDescription", val.printer_description);
|
dict.Set("description", val.printer_description);
|
||||||
dict.Set("printerStatus", val.printer_status);
|
dict.Set("status", val.printer_status);
|
||||||
dict.Set("isDefault", val.is_default);
|
dict.Set("isDefault", val.is_default);
|
||||||
dict.Set("options", val.options);
|
dict.Set("options", val.options);
|
||||||
return dict.GetHandle();
|
return dict.GetHandle();
|
||||||
|
@ -1872,7 +1872,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||||
&WebContents::UnregisterServiceWorker)
|
&WebContents::UnregisterServiceWorker)
|
||||||
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
|
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
|
||||||
.SetMethod("print", &WebContents::Print)
|
.SetMethod("print", &WebContents::Print)
|
||||||
.SetMethod("printerList", &WebContents::GetPrinterList)
|
.SetMethod("getPrinters", &WebContents::GetPrinterList)
|
||||||
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
|
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
|
||||||
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
|
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
|
||||||
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
|
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
|
||||||
|
|
|
@ -916,39 +916,41 @@ Unregisters any ServiceWorker if present and returns a boolean as
|
||||||
response to `callback` when the JS promise is fulfilled or false
|
response to `callback` when the JS promise is fulfilled or false
|
||||||
when the JS promise is rejected.
|
when the JS promise is rejected.
|
||||||
|
|
||||||
#### `contents.printerList()`
|
#### `contents.getPrinters()`
|
||||||
|
|
||||||
Get the system printer list, the result is an array of printer description.
|
Get the system printer list, the result is an array of printer descriptions.
|
||||||
eg:
|
|
||||||
````js
|
|
||||||
[{ printerName: 'Zebra_LP2844',
|
|
||||||
printerDescription: 'Zebra LP2844',
|
|
||||||
printerStatus: 3,
|
|
||||||
isDefault: 0,
|
|
||||||
options:
|
|
||||||
{ copies: '1',
|
|
||||||
'device-uri': 'usb://Zebra/LP2844?location=14200000',
|
|
||||||
finishings: '3',
|
|
||||||
'job-cancel-after': '10800',
|
|
||||||
'job-hold-until': 'no-hold',
|
|
||||||
'job-priority': '50',
|
|
||||||
'job-sheets': 'none,none',
|
|
||||||
'marker-change-time': '0',
|
|
||||||
'number-up': '1',
|
|
||||||
'printer-commands': 'none',
|
|
||||||
'printer-info': 'Zebra LP2844',
|
|
||||||
'printer-is-accepting-jobs': 'true',
|
|
||||||
'printer-is-shared': 'true',
|
|
||||||
'printer-location': '',
|
|
||||||
'printer-make-and-model': 'Zebra EPL2 Label Printer',
|
|
||||||
'printer-state': '3',
|
|
||||||
'printer-state-change-time': '1484872644',
|
|
||||||
'printer-state-reasons': 'offline-report',
|
|
||||||
'printer-type': '36932',
|
|
||||||
'printer-uri-supported': 'ipp://localhost/printers/Zebra_LP2844',
|
|
||||||
system_driverinfo: 'Z' } }]
|
|
||||||
````
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
[{
|
||||||
|
name: 'Zebra_LP2844',
|
||||||
|
description: 'Zebra LP2844',
|
||||||
|
status: 3,
|
||||||
|
isDefault: 0,
|
||||||
|
options: {
|
||||||
|
copies: '1',
|
||||||
|
'device-uri': 'usb://Zebra/LP2844?location=14200000',
|
||||||
|
finishings: '3',
|
||||||
|
'job-cancel-after': '10800',
|
||||||
|
'job-hold-until': 'no-hold',
|
||||||
|
'job-priority': '50',
|
||||||
|
'job-sheets': 'none,none',
|
||||||
|
'marker-change-time': '0',
|
||||||
|
'number-up': '1',
|
||||||
|
'printer-commands': 'none',
|
||||||
|
'printer-info': 'Zebra LP2844',
|
||||||
|
'printer-is-accepting-jobs': 'true',
|
||||||
|
'printer-is-shared': 'true',
|
||||||
|
'printer-location': '',
|
||||||
|
'printer-make-and-model': 'Zebra EPL2 Label Printer',
|
||||||
|
'printer-state': '3',
|
||||||
|
'printer-state-change-time': '1484872644',
|
||||||
|
'printer-state-reasons': 'offline-report',
|
||||||
|
'printer-type': '36932',
|
||||||
|
'printer-uri-supported': 'ipp://localhost/printers/Zebra_LP2844',
|
||||||
|
system_driverinfo: 'Z'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
#### `contents.print([options])`
|
#### `contents.print([options])`
|
||||||
|
|
||||||
|
|
|
@ -1125,8 +1125,8 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
w.loadURL('data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E')
|
w.loadURL('data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E')
|
||||||
w.webContents.once('did-finish-load', function () {
|
w.webContents.once('did-finish-load', function () {
|
||||||
const pl = w.webContents.printerList()
|
const printers = w.webContents.getPrinters()
|
||||||
assert.equal(Array.isArray(pl), true)
|
assert.equal(Array.isArray(printers), true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue