index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. // import * as edge from 'edge-js';
  3. exports.__esModule = true;
  4. // let designerReport = edge.func({
  5. // assemblyFile: 'lib/GetEasy.Node.Printer.dll',
  6. // typeName: 'GetEasy.Node.Printer.NodeReportDesigner',
  7. // methodName: 'DesignerReport'
  8. // });
  9. // designerReport('', true);
  10. var ffi = require("ffi");
  11. var os = require("os");
  12. var cpu = os.arch() === "x64" ? "64" : "86";
  13. var callback = ffi.Callback('void', ['int', 'string'], function (id, name) {
  14. console.log("id: ", id);
  15. console.log("name: ", name);
  16. });
  17. var dll = ffi.Library(__dirname + "/dll/GetEasy.Node.Printer." + cpu + ".dll", {
  18. designerReport: ["void", ["string", "string", "pointer"]],
  19. reportShowPreview: ["void", ["string", "string"]],
  20. reportPrinter: ["void", ["string", "string"]]
  21. });
  22. var ReportApi = /** @class */ (function () {
  23. function ReportApi() {
  24. }
  25. /**
  26. *设计模板
  27. *
  28. * @param {string} fileName 模板
  29. * @param {string} tempData 临时演示数据
  30. * @memberof ReportApi
  31. */
  32. ReportApi.designerReport = function (template, tempData, saveCallback) {
  33. var callbackPointer = ffi.Callback('bool', ['string'], saveCallback);
  34. dll.designerReport(template, tempData, callbackPointer);
  35. };
  36. /**
  37. *打印预览
  38. *
  39. * @param {string} fileName 模板路径
  40. * @param {string} jsonData 数据
  41. * @memberof ReportApi
  42. */
  43. ReportApi.reportShowPreview = function (fileName, jsonData) {
  44. dll.reportPrinter(fileName, jsonData);
  45. };
  46. /**
  47. *打印
  48. *
  49. * @param {string} fileName 模板路径
  50. * @param {string} jsonData 数据
  51. * @memberof ReportApi
  52. */
  53. ReportApi.reportPrinter = function (fileName, jsonData) {
  54. dll.reportPrinter(fileName, jsonData);
  55. };
  56. return ReportApi;
  57. }());
  58. exports["default"] = ReportApi;