@esslassi/electron-printer 0.0.7 → 0.0.9
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 +318 -318
- package/binding.gyp +57 -57
- package/lib/electronPrinter.js +17 -18
- package/lib/native.d.ts +2 -0
- package/lib/native.js +12 -0
- package/package.json +10 -3
- package/src/linux_printer.cpp +370 -370
- package/src/linux_printer.h +30 -30
- package/src/mac_printer.cpp +372 -372
- package/src/mac_printer.h +30 -30
- package/src/main.cpp +50 -50
- package/src/print.cpp +352 -352
- package/src/printer_factory.cpp +19 -19
- package/src/printer_factory.h +12 -12
- package/src/printer_interface.h +66 -66
- package/src/windows_printer.cpp +346 -346
- package/src/windows_printer.h +63 -63
- package/test.js +0 -120
package/src/mac_printer.h
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
#ifndef MAC_PRINTER_H
|
|
2
|
-
#define MAC_PRINTER_H
|
|
3
|
-
|
|
4
|
-
#include "printer_interface.h"
|
|
5
|
-
|
|
6
|
-
class MacPrinter : public PrinterInterface
|
|
7
|
-
{
|
|
8
|
-
public:
|
|
9
|
-
std::vector<PrinterDetailsNative> GetPrinters() override;
|
|
10
|
-
PrinterDetailsNative GetPrinter(const std::string &printerName) override;
|
|
11
|
-
std::string GetDefaultPrinterName() override;
|
|
12
|
-
|
|
13
|
-
DriverOptions GetPrinterDriverOptions(const std::string &printerName) override;
|
|
14
|
-
std::string GetSelectedPaperSize(const std::string &printerName) override;
|
|
15
|
-
|
|
16
|
-
int PrintDirect(const std::string &printerName,
|
|
17
|
-
const std::vector<uint8_t> &data,
|
|
18
|
-
const std::string &type,
|
|
19
|
-
const StringMap &options) override;
|
|
20
|
-
|
|
21
|
-
int PrintFile(const std::string &printerName,
|
|
22
|
-
const std::string &filename) override;
|
|
23
|
-
|
|
24
|
-
std::vector<std::string> GetSupportedPrintFormats() override;
|
|
25
|
-
|
|
26
|
-
JobDetailsNative GetJob(const std::string &printerName, int jobId) override;
|
|
27
|
-
void SetJob(const std::string &printerName, int jobId, const std::string &command) override;
|
|
28
|
-
std::vector<std::string> GetSupportedJobCommands() override;
|
|
29
|
-
};
|
|
30
|
-
|
|
1
|
+
#ifndef MAC_PRINTER_H
|
|
2
|
+
#define MAC_PRINTER_H
|
|
3
|
+
|
|
4
|
+
#include "printer_interface.h"
|
|
5
|
+
|
|
6
|
+
class MacPrinter : public PrinterInterface
|
|
7
|
+
{
|
|
8
|
+
public:
|
|
9
|
+
std::vector<PrinterDetailsNative> GetPrinters() override;
|
|
10
|
+
PrinterDetailsNative GetPrinter(const std::string &printerName) override;
|
|
11
|
+
std::string GetDefaultPrinterName() override;
|
|
12
|
+
|
|
13
|
+
DriverOptions GetPrinterDriverOptions(const std::string &printerName) override;
|
|
14
|
+
std::string GetSelectedPaperSize(const std::string &printerName) override;
|
|
15
|
+
|
|
16
|
+
int PrintDirect(const std::string &printerName,
|
|
17
|
+
const std::vector<uint8_t> &data,
|
|
18
|
+
const std::string &type,
|
|
19
|
+
const StringMap &options) override;
|
|
20
|
+
|
|
21
|
+
int PrintFile(const std::string &printerName,
|
|
22
|
+
const std::string &filename) override;
|
|
23
|
+
|
|
24
|
+
std::vector<std::string> GetSupportedPrintFormats() override;
|
|
25
|
+
|
|
26
|
+
JobDetailsNative GetJob(const std::string &printerName, int jobId) override;
|
|
27
|
+
void SetJob(const std::string &printerName, int jobId, const std::string &command) override;
|
|
28
|
+
std::vector<std::string> GetSupportedJobCommands() override;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
31
|
#endif
|
package/src/main.cpp
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
#include <napi.h>
|
|
2
|
-
|
|
3
|
-
/* Forward declarations (implemented in print.cpp) */
|
|
4
|
-
|
|
5
|
-
Napi::Value getPrinters(const Napi::CallbackInfo &info);
|
|
6
|
-
Napi::Value getPrinter(const Napi::CallbackInfo &info);
|
|
7
|
-
Napi::Value getPrinterDriverOptions(const Napi::CallbackInfo &info);
|
|
8
|
-
Napi::Value getSelectedPaperSize(const Napi::CallbackInfo &info);
|
|
9
|
-
Napi::Value getDefaultPrinterName(const Napi::CallbackInfo &info);
|
|
10
|
-
|
|
11
|
-
Napi::Value printDirect(const Napi::CallbackInfo &info);
|
|
12
|
-
Napi::Value printFile(const Napi::CallbackInfo &info);
|
|
13
|
-
|
|
14
|
-
Napi::Value getSupportedPrintFormats(const Napi::CallbackInfo &info);
|
|
15
|
-
|
|
16
|
-
Napi::Value getJob(const Napi::CallbackInfo &info);
|
|
17
|
-
Napi::Value setJob(const Napi::CallbackInfo &info);
|
|
18
|
-
Napi::Value getSupportedJobCommands(const Napi::CallbackInfo &info);
|
|
19
|
-
|
|
20
|
-
/* Module initialization */
|
|
21
|
-
|
|
22
|
-
Napi::Object Init(Napi::Env env, Napi::Object exports)
|
|
23
|
-
{
|
|
24
|
-
// Printer listing
|
|
25
|
-
exports.Set("getPrinters", Napi::Function::New(env, getPrinters));
|
|
26
|
-
exports.Set("getPrinter", Napi::Function::New(env, getPrinter));
|
|
27
|
-
exports.Set("getPrinterDriverOptions", Napi::Function::New(env, getPrinterDriverOptions));
|
|
28
|
-
exports.Set("getSelectedPaperSize", Napi::Function::New(env, getSelectedPaperSize));
|
|
29
|
-
exports.Set("getDefaultPrinterName", Napi::Function::New(env, getDefaultPrinterName));
|
|
30
|
-
|
|
31
|
-
// Printing
|
|
32
|
-
exports.Set("printDirect", Napi::Function::New(env, printDirect));
|
|
33
|
-
exports.Set("printFile", Napi::Function::New(env, printFile));
|
|
34
|
-
|
|
35
|
-
// Capabilities
|
|
36
|
-
exports.Set("getSupportedPrintFormats", Napi::Function::New(env, getSupportedPrintFormats));
|
|
37
|
-
exports.Set("getSupportedJobCommands", Napi::Function::New(env, getSupportedJobCommands));
|
|
38
|
-
|
|
39
|
-
// Job management
|
|
40
|
-
exports.Set("getJob", Napi::Function::New(env, getJob));
|
|
41
|
-
exports.Set("setJob", Napi::Function::New(env, setJob));
|
|
42
|
-
|
|
43
|
-
return exports;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/*
|
|
47
|
-
IMPORTANT:
|
|
48
|
-
Module name MUST match bindings('electron_printer')
|
|
49
|
-
and binding.gyp target_name
|
|
50
|
-
*/
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
|
|
3
|
+
/* Forward declarations (implemented in print.cpp) */
|
|
4
|
+
|
|
5
|
+
Napi::Value getPrinters(const Napi::CallbackInfo &info);
|
|
6
|
+
Napi::Value getPrinter(const Napi::CallbackInfo &info);
|
|
7
|
+
Napi::Value getPrinterDriverOptions(const Napi::CallbackInfo &info);
|
|
8
|
+
Napi::Value getSelectedPaperSize(const Napi::CallbackInfo &info);
|
|
9
|
+
Napi::Value getDefaultPrinterName(const Napi::CallbackInfo &info);
|
|
10
|
+
|
|
11
|
+
Napi::Value printDirect(const Napi::CallbackInfo &info);
|
|
12
|
+
Napi::Value printFile(const Napi::CallbackInfo &info);
|
|
13
|
+
|
|
14
|
+
Napi::Value getSupportedPrintFormats(const Napi::CallbackInfo &info);
|
|
15
|
+
|
|
16
|
+
Napi::Value getJob(const Napi::CallbackInfo &info);
|
|
17
|
+
Napi::Value setJob(const Napi::CallbackInfo &info);
|
|
18
|
+
Napi::Value getSupportedJobCommands(const Napi::CallbackInfo &info);
|
|
19
|
+
|
|
20
|
+
/* Module initialization */
|
|
21
|
+
|
|
22
|
+
Napi::Object Init(Napi::Env env, Napi::Object exports)
|
|
23
|
+
{
|
|
24
|
+
// Printer listing
|
|
25
|
+
exports.Set("getPrinters", Napi::Function::New(env, getPrinters));
|
|
26
|
+
exports.Set("getPrinter", Napi::Function::New(env, getPrinter));
|
|
27
|
+
exports.Set("getPrinterDriverOptions", Napi::Function::New(env, getPrinterDriverOptions));
|
|
28
|
+
exports.Set("getSelectedPaperSize", Napi::Function::New(env, getSelectedPaperSize));
|
|
29
|
+
exports.Set("getDefaultPrinterName", Napi::Function::New(env, getDefaultPrinterName));
|
|
30
|
+
|
|
31
|
+
// Printing
|
|
32
|
+
exports.Set("printDirect", Napi::Function::New(env, printDirect));
|
|
33
|
+
exports.Set("printFile", Napi::Function::New(env, printFile));
|
|
34
|
+
|
|
35
|
+
// Capabilities
|
|
36
|
+
exports.Set("getSupportedPrintFormats", Napi::Function::New(env, getSupportedPrintFormats));
|
|
37
|
+
exports.Set("getSupportedJobCommands", Napi::Function::New(env, getSupportedJobCommands));
|
|
38
|
+
|
|
39
|
+
// Job management
|
|
40
|
+
exports.Set("getJob", Napi::Function::New(env, getJob));
|
|
41
|
+
exports.Set("setJob", Napi::Function::New(env, setJob));
|
|
42
|
+
|
|
43
|
+
return exports;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
IMPORTANT:
|
|
48
|
+
Module name MUST match bindings('electron_printer')
|
|
49
|
+
and binding.gyp target_name
|
|
50
|
+
*/
|
|
51
51
|
NODE_API_MODULE(electron_printer, Init)
|