@resolveio/server-lib 20.0.26 → 20.0.28
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/client-server-app.js +1 -47
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +1 -50
- package/collections/app-status.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -53
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -88
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -84
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -65
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -60
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -72
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +1 -55
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -63
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -67
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log-ts.collection.js +1 -77
- package/collections/log-ts.collection.js.map +1 -1
- package/collections/log.collection.js +1 -76
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -64
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -65
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -62
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -74
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -68
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -55
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -108
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -86
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -148
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -93
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -56
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -265
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +1 -101
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +1 -87
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +1 -58
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +1 -763
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -11
- package/http/health.js.map +1 -1
- package/http/home.js +1 -65
- package/http/home.js.map +1 -1
- package/index.js +1 -126
- package/index.js.map +1 -1
- package/managers/cron.manager.js +1 -322
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +1 -593
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1 -2259
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +1 -350
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -1110
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +1 -102
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +1 -291
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +1 -616
- package/methods/aws.js.map +1 -1
- package/methods/collections.js +1 -499
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +1 -121
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1 -1337
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -8
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +1 -370
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +1 -564
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +1 -731
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +1 -859
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +1 -245
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -3
- package/models/app-status.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +1 -3
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +1 -3
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +1 -3
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +1 -3
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +1 -3
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +1 -3
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +1 -3
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +1 -3
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +1 -3
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +1 -3
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +1 -3
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +1 -3
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +1 -3
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +1 -3
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-response.model.js +1 -3
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +1 -3
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +1 -3
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-memory.model.js +1 -3
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +1 -3
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +1 -3
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +1 -23
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -3
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +1 -3
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +1 -3
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +1 -3
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +1 -3
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +1 -3
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +1 -3
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +1 -3
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +1 -3
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +1 -3
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +1 -3
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +1 -3
- package/models/user.model.js.map +1 -1
- package/package.json +6 -4
- package/public_api.js +1 -74
- package/public_api.js.map +1 -1
- package/publications/app-status.js +1 -16
- package/publications/app-status.js.map +1 -1
- package/publications/cron-jobs.js +1 -32
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -36
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -22
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -164
- package/publications/logs.js.map +1 -1
- package/publications/method-responses.js +1 -16
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -16
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -42
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +1 -89
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -50
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -16
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -16
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -16
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +1 -770
- package/server-app.js.map +1 -1
- package/util/common.js +1 -546
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +1 -452
- package/util/schema-report-builder.js.map +1 -1
package/methods/pdf.js
CHANGED
|
@@ -1,732 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.loadPDFMethods = void 0;
|
|
40
|
-
var fs = require("fs");
|
|
41
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
42
|
-
var pdf_lib_1 = require("pdf-lib");
|
|
43
|
-
var puppeteer = require("puppeteer");
|
|
44
|
-
var path = require("path");
|
|
45
|
-
var pdfCnt = 0;
|
|
46
|
-
function loadPDFMethods(methodManager) {
|
|
47
|
-
methodManager.methods({
|
|
48
|
-
generatePDF: {
|
|
49
|
-
check: new simpl_schema_1.default({
|
|
50
|
-
html: {
|
|
51
|
-
type: String
|
|
52
|
-
},
|
|
53
|
-
fileName: {
|
|
54
|
-
type: String
|
|
55
|
-
},
|
|
56
|
-
orientation: {
|
|
57
|
-
type: String,
|
|
58
|
-
optional: true
|
|
59
|
-
},
|
|
60
|
-
fontSize: {
|
|
61
|
-
type: String,
|
|
62
|
-
optional: true
|
|
63
|
-
},
|
|
64
|
-
upload: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
optional: true
|
|
67
|
-
},
|
|
68
|
-
uploadFileOrder: {
|
|
69
|
-
type: Number,
|
|
70
|
-
optional: true
|
|
71
|
-
},
|
|
72
|
-
uploadFileType: {
|
|
73
|
-
type: String,
|
|
74
|
-
optional: true
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
function: function (html, fileName, orientation, fontSize, upload, uploadFileOrder, uploadFileType) {
|
|
78
|
-
var _this = this;
|
|
79
|
-
if (orientation === void 0) { orientation = 'portrait'; }
|
|
80
|
-
if (fontSize === void 0) { fontSize = '12px'; }
|
|
81
|
-
if (upload === void 0) { upload = false; }
|
|
82
|
-
if (uploadFileOrder === void 0) { uploadFileOrder = -1; }
|
|
83
|
-
if (uploadFileType === void 0) { uploadFileType = ''; }
|
|
84
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
85
|
-
var args, browser, page, pathToFont, dejavuserif_woff, dejavuserifBold_woff, dejavuserifItalic_woff, dejavuserifBoldItalic_woff, content, tmpFileName;
|
|
86
|
-
var _this = this;
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
args = [
|
|
91
|
-
"--disable-dev-shm-usage",
|
|
92
|
-
"--no-sandbox",
|
|
93
|
-
"--disable-setuid-sandbox",
|
|
94
|
-
"--disable-accelerated-2d-canvas",
|
|
95
|
-
"--disable-gpu",
|
|
96
|
-
"--allow-file-access-from-files",
|
|
97
|
-
"--enable-local-file-accesses",
|
|
98
|
-
'--font-render-hinting=none'
|
|
99
|
-
];
|
|
100
|
-
return [4 /*yield*/, puppeteer.launch({
|
|
101
|
-
headless: 'new',
|
|
102
|
-
devtools: false,
|
|
103
|
-
ignoreHTTPSErrors: true,
|
|
104
|
-
args: args,
|
|
105
|
-
ignoreDefaultArgs: ["--disable-extensions"]
|
|
106
|
-
})];
|
|
107
|
-
case 1:
|
|
108
|
-
browser = _a.sent();
|
|
109
|
-
return [4 /*yield*/, browser.newPage()];
|
|
110
|
-
case 2:
|
|
111
|
-
page = _a.sent();
|
|
112
|
-
pathToFont = '';
|
|
113
|
-
if (fs.existsSync(path.join(__dirname, ('../private/fonts/dejavuserif.woff')))) {
|
|
114
|
-
pathToFont = path.join(__dirname, ('../private/fonts/'));
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
if (fs.existsSync(path.join(this.clientDir, ('./private/fonts/dejavuserif.woff')))) {
|
|
118
|
-
pathToFont = path.join(this.clientDir, ('./private/fonts/'));
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
pathToFont = '/usr/share/fonts/dejavu/';
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
dejavuserif_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif.woff').buffer).toString('base64');
|
|
125
|
-
dejavuserifBold_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif-bold.woff').buffer).toString('base64');
|
|
126
|
-
dejavuserifItalic_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif-italic.woff').buffer).toString('base64');
|
|
127
|
-
dejavuserifBoldItalic_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif-bolditalic.woff').buffer).toString('base64');
|
|
128
|
-
content = "\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<style type=\"text/css\">\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserif_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserifBold_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserifItalic_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserifBoldItalic_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tbody {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-size: " + (fontSize ? fontSize : '12px') + ";\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.row {\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\t\t\tflex-wrap: wrap;\n\t\t\t\t\t\t\t\t\t-webkit-flex-wrap: wrap;\n\t\t\t\t\t\t\t\t\tpage-break-inside: avoid !important;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.page-break {\n\t\t\t\t\t\t\t\t\tpage-break-before: always !important;\n\t\t\t\t\t\t\t\t\tpadding-top: 1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\tpadding : 2px;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell-no-padding {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: center;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-left {\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-start;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-right {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-end;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.box {\n\t\t\t\t\t\t\t\t\tborder: 1px solid black;\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.boxNoBorder {\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpre {\n\t\t\t\t\t\t\t\t\twhite-space: pre-wrap; /* css-3 */\n\t\t\t\t\t\t\t\t\twhite-space: -moz-pre-wrap; /* Mozilla, since 1999 */\n\t\t\t\t\t\t\t\t\twhite-space: -pre-wrap; /* Opera 4-6 */\n\t\t\t\t\t\t\t\t\twhite-space: -o-pre-wrap; /* Opera 7 */\n\t\t\t\t\t\t\t\t\tword-wrap: break-word; /* Internet Explorer 5.5+ */\n\t\t\t\t\t\t\t\t\tfont-size: 12px;\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif'; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t" + html.replace(new RegExp('flex-basis:', 'g'), '-webkit-flex-basis:').replace(new RegExp('flex:', 'g'), '-webkit-flex:') + '</body>';
|
|
129
|
-
return [4 /*yield*/, page.setContent(content, { waitUntil: ['domcontentloaded', 'load', 'networkidle0'] })];
|
|
130
|
-
case 3:
|
|
131
|
-
_a.sent();
|
|
132
|
-
return [4 /*yield*/, page.evaluateHandle('document.fonts.ready')];
|
|
133
|
-
case 4:
|
|
134
|
-
_a.sent();
|
|
135
|
-
tmpFileName = (pdfCnt++) + '-' + fileName.replace(new RegExp(/[^0-9\.a-zA-Z]/g), '');
|
|
136
|
-
return [4 /*yield*/, page.pdf({
|
|
137
|
-
scale: 1,
|
|
138
|
-
landscape: orientation === 'portrait' ? false : true,
|
|
139
|
-
format: 'letter',
|
|
140
|
-
margin: {
|
|
141
|
-
top: '1cm',
|
|
142
|
-
bottom: '1cm',
|
|
143
|
-
left: '1cm',
|
|
144
|
-
right: '1cm'
|
|
145
|
-
},
|
|
146
|
-
printBackground: true,
|
|
147
|
-
displayHeaderFooter: true,
|
|
148
|
-
headerTemplate: "\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t#header { \n\t\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t",
|
|
149
|
-
footerTemplate: "\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t#footer { \n\t\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important;\n\t\t\t\t\t\t\t\t\tfont-size: 10px;\n\t\t\t\t\t\t\t\t\tfont-family: san-serif;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<div style=\"padding-bottom: 2px; padding-right: 15px; text-align: right; width: 100%;\">\n\t\t\t\t\t\t\t\tPage <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t",
|
|
150
|
-
path: path.join(__dirname, (tmpFileName)),
|
|
151
|
-
timeout: 0
|
|
152
|
-
})];
|
|
153
|
-
case 5:
|
|
154
|
-
_a.sent();
|
|
155
|
-
return [4 /*yield*/, browser.close()];
|
|
156
|
-
case 6:
|
|
157
|
-
_a.sent();
|
|
158
|
-
if (fs.existsSync(path.join(__dirname, (tmpFileName)))) {
|
|
159
|
-
fs.readFile(path.join(__dirname, (tmpFileName)), function (errRead, data) {
|
|
160
|
-
if (!errRead) {
|
|
161
|
-
fs.unlinkSync(path.join(__dirname, (tmpFileName)));
|
|
162
|
-
if (!upload) {
|
|
163
|
-
resolve('data:application/pdf;base64,' + Buffer.from(data).toString('base64'));
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
var fileData = 'data:application/pdf;base64,' + Buffer.from(data).toString('base64');
|
|
167
|
-
_this.callMethodInternal('uploadFileAndSave', fileName, fileData, (4 * Math.ceil(fileData.length / 3)), uploadFileOrder !== null ? uploadFileOrder : -1, uploadFileType, false, function (err, res) {
|
|
168
|
-
if (err) {
|
|
169
|
-
reject(err);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
resolve(res);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
reject('No file');
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
reject('No tmp file');
|
|
184
|
-
console.log('No tmp file ', tmpFileName);
|
|
185
|
-
}
|
|
186
|
-
return [2 /*return*/];
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}); });
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
generatePDFNoPageNumber: {
|
|
193
|
-
check: new simpl_schema_1.default({
|
|
194
|
-
html: {
|
|
195
|
-
type: String
|
|
196
|
-
},
|
|
197
|
-
fileName: {
|
|
198
|
-
type: String
|
|
199
|
-
},
|
|
200
|
-
orientation: {
|
|
201
|
-
type: String,
|
|
202
|
-
optional: true
|
|
203
|
-
},
|
|
204
|
-
fontSize: {
|
|
205
|
-
type: String,
|
|
206
|
-
optional: true
|
|
207
|
-
},
|
|
208
|
-
upload: {
|
|
209
|
-
type: Boolean,
|
|
210
|
-
optional: true
|
|
211
|
-
},
|
|
212
|
-
uploadFileOrder: {
|
|
213
|
-
type: Number,
|
|
214
|
-
optional: true
|
|
215
|
-
},
|
|
216
|
-
uploadFileType: {
|
|
217
|
-
type: String,
|
|
218
|
-
optional: true
|
|
219
|
-
}
|
|
220
|
-
}),
|
|
221
|
-
function: function (html, fileName, orientation, fontSize, upload, uploadFileOrder, uploadFileType) {
|
|
222
|
-
var _this = this;
|
|
223
|
-
if (orientation === void 0) { orientation = 'portrait'; }
|
|
224
|
-
if (fontSize === void 0) { fontSize = '12px'; }
|
|
225
|
-
if (upload === void 0) { upload = false; }
|
|
226
|
-
if (uploadFileOrder === void 0) { uploadFileOrder = -1; }
|
|
227
|
-
if (uploadFileType === void 0) { uploadFileType = ''; }
|
|
228
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
229
|
-
var args, browser, page, pathToFont, dejavuserif_woff, dejavuserifBold_woff, dejavuserifItalic_woff, dejavuserifBoldItalic_woff, content, tmpFileName;
|
|
230
|
-
var _this = this;
|
|
231
|
-
return __generator(this, function (_a) {
|
|
232
|
-
switch (_a.label) {
|
|
233
|
-
case 0:
|
|
234
|
-
args = [
|
|
235
|
-
"--disable-dev-shm-usage",
|
|
236
|
-
"--no-sandbox",
|
|
237
|
-
"--disable-setuid-sandbox",
|
|
238
|
-
"--disable-accelerated-2d-canvas",
|
|
239
|
-
"--disable-gpu",
|
|
240
|
-
"--allow-file-access-from-files",
|
|
241
|
-
"--enable-local-file-accesses",
|
|
242
|
-
'--font-render-hinting=none'
|
|
243
|
-
];
|
|
244
|
-
return [4 /*yield*/, puppeteer.launch({
|
|
245
|
-
headless: 'new',
|
|
246
|
-
devtools: false,
|
|
247
|
-
ignoreHTTPSErrors: true,
|
|
248
|
-
args: args,
|
|
249
|
-
ignoreDefaultArgs: ["--disable-extensions"]
|
|
250
|
-
})];
|
|
251
|
-
case 1:
|
|
252
|
-
browser = _a.sent();
|
|
253
|
-
return [4 /*yield*/, browser.newPage()];
|
|
254
|
-
case 2:
|
|
255
|
-
page = _a.sent();
|
|
256
|
-
pathToFont = '';
|
|
257
|
-
if (fs.existsSync(path.join(__dirname, ('../private/fonts/dejavuserif.woff')))) {
|
|
258
|
-
pathToFont = path.join(__dirname, ('../private/fonts/'));
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
if (fs.existsSync(path.join(this.clientDir, ('./private/fonts/dejavuserif.woff')))) {
|
|
262
|
-
pathToFont = path.join(this.clientDir, ('./private/fonts/'));
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
pathToFont = '/usr/share/fonts/dejavu/';
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
dejavuserif_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif.woff').buffer).toString('base64');
|
|
269
|
-
dejavuserifBold_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif-bold.woff').buffer).toString('base64');
|
|
270
|
-
dejavuserifItalic_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif-italic.woff').buffer).toString('base64');
|
|
271
|
-
dejavuserifBoldItalic_woff = 'data:application/font-woff;base64,' + Buffer.from(fs.readFileSync(pathToFont + 'dejavuserif-bolditalic.woff').buffer).toString('base64');
|
|
272
|
-
content = "\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<style type=\"text/css\">\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserif_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserifBold_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserifItalic_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\"" + dejavuserifBoldItalic_woff + "\") format('woff');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tbody {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-size: " + (fontSize ? fontSize : '12px') + ";\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.row {\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\t\t\tflex-wrap: wrap;\n\t\t\t\t\t\t\t\t\t-webkit-flex-wrap: wrap;\n\t\t\t\t\t\t\t\t\tpage-break-inside: avoid !important;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.page-break {\n\t\t\t\t\t\t\t\t\tpage-break-before: always !important;\n\t\t\t\t\t\t\t\t\tpadding-top: 1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\tpadding : 2px;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell-no-padding {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: center;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-left {\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-start;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-right {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-end;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.box {\n\t\t\t\t\t\t\t\t\tborder: 1px solid black;\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.boxNoBorder {\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpre {\n\t\t\t\t\t\t\t\t\twhite-space: pre-wrap; /* css-3 */\n\t\t\t\t\t\t\t\t\twhite-space: -moz-pre-wrap; /* Mozilla, since 1999 */\n\t\t\t\t\t\t\t\t\twhite-space: -pre-wrap; /* Opera 4-6 */\n\t\t\t\t\t\t\t\t\twhite-space: -o-pre-wrap; /* Opera 7 */\n\t\t\t\t\t\t\t\t\tword-wrap: break-word; /* Internet Explorer 5.5+ */\n\t\t\t\t\t\t\t\t\tfont-size: 12px;\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif'; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<meta charset=\"UTF-8\">\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t" + html.replace(new RegExp('flex-basis:', 'g'), '-webkit-flex-basis:').replace(new RegExp('flex:', 'g'), '-webkit-flex:') + '</body>';
|
|
273
|
-
return [4 /*yield*/, page.setContent(content, { waitUntil: ['domcontentloaded', 'load', 'networkidle0'] })];
|
|
274
|
-
case 3:
|
|
275
|
-
_a.sent();
|
|
276
|
-
return [4 /*yield*/, page.evaluateHandle('document.fonts.ready')];
|
|
277
|
-
case 4:
|
|
278
|
-
_a.sent();
|
|
279
|
-
tmpFileName = (pdfCnt++) + '-' + fileName.replace(new RegExp(/[^0-9\.a-zA-Z]/g), '');
|
|
280
|
-
return [4 /*yield*/, page.pdf({
|
|
281
|
-
scale: 1,
|
|
282
|
-
landscape: orientation === 'portrait' ? false : true,
|
|
283
|
-
format: 'letter',
|
|
284
|
-
margin: {
|
|
285
|
-
top: '1cm',
|
|
286
|
-
bottom: '1cm',
|
|
287
|
-
left: '1cm',
|
|
288
|
-
right: '1cm'
|
|
289
|
-
},
|
|
290
|
-
printBackground: true,
|
|
291
|
-
displayHeaderFooter: true,
|
|
292
|
-
headerTemplate: "\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t#header { \n\t\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t",
|
|
293
|
-
footerTemplate: "\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t#footer { \n\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important;\n\t\t\t\t\t\t\t\tfont-size: 10px;\n\t\t\t\t\t\t\t\tfont-family: san-serif;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t\t<div style=\"padding-bottom: 2px; padding-right: 15px; text-align: right; width: 100%;\">\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t",
|
|
294
|
-
path: path.join(__dirname, (tmpFileName)),
|
|
295
|
-
timeout: 0
|
|
296
|
-
})];
|
|
297
|
-
case 5:
|
|
298
|
-
_a.sent();
|
|
299
|
-
return [4 /*yield*/, browser.close()];
|
|
300
|
-
case 6:
|
|
301
|
-
_a.sent();
|
|
302
|
-
if (fs.existsSync(path.join(__dirname, (tmpFileName)))) {
|
|
303
|
-
fs.readFile(path.join(__dirname, (tmpFileName)), function (errRead, data) {
|
|
304
|
-
if (!errRead) {
|
|
305
|
-
fs.unlinkSync(path.join(__dirname, (tmpFileName)));
|
|
306
|
-
if (!upload) {
|
|
307
|
-
resolve('data:application/pdf;base64,' + Buffer.from(data).toString('base64'));
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
var fileData = 'data:application/pdf;base64,' + Buffer.from(data).toString('base64');
|
|
311
|
-
_this.callMethodInternal('uploadFileAndSave', fileName, fileData, (4 * Math.ceil(fileData.length / 3)), uploadFileOrder !== null ? uploadFileOrder : -1, uploadFileType, false, function (err, res) {
|
|
312
|
-
if (err) {
|
|
313
|
-
reject(err);
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
resolve(res);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
reject('No file');
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
reject('No tmp file');
|
|
328
|
-
console.log('No tmp file ', tmpFileName);
|
|
329
|
-
}
|
|
330
|
-
return [2 /*return*/];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}); });
|
|
334
|
-
}
|
|
335
|
-
},
|
|
336
|
-
mergePDFResolve: {
|
|
337
|
-
check: new simpl_schema_1.default({
|
|
338
|
-
fileKeys: {
|
|
339
|
-
type: Array
|
|
340
|
-
},
|
|
341
|
-
'fileKeys.$': {
|
|
342
|
-
type: String
|
|
343
|
-
},
|
|
344
|
-
fileName: {
|
|
345
|
-
type: String
|
|
346
|
-
},
|
|
347
|
-
fileType: {
|
|
348
|
-
type: String,
|
|
349
|
-
optional: true
|
|
350
|
-
}
|
|
351
|
-
}),
|
|
352
|
-
function: function (fileKeys, fileName, fileType) {
|
|
353
|
-
var _this = this;
|
|
354
|
-
return new Promise(function (resolve, reject) {
|
|
355
|
-
_this.callMethodInternal('getSignedUrls', fileKeys, 900, function (errSigneds, resSigneds) {
|
|
356
|
-
if (resSigneds && resSigneds.length) {
|
|
357
|
-
var promises_1 = [];
|
|
358
|
-
resSigneds.forEach(function (signedUrl) {
|
|
359
|
-
promises_1.push(_this.callMethodInternal('getDataURIfromURL', signedUrl));
|
|
360
|
-
});
|
|
361
|
-
Promise.all(promises_1).then(function (fileDatas) { return __awaiter(_this, void 0, void 0, function () {
|
|
362
|
-
var mergedPdf, i, fileData, pdf, copiedPages, pdf, img, page, imgDim, copiedPages, pdf, img, page, imgDim, copiedPages, error_1, mergedPDFUint8, b64PDF;
|
|
363
|
-
return __generator(this, function (_a) {
|
|
364
|
-
switch (_a.label) {
|
|
365
|
-
case 0: return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
366
|
-
case 1:
|
|
367
|
-
mergedPdf = _a.sent();
|
|
368
|
-
i = 0;
|
|
369
|
-
_a.label = 2;
|
|
370
|
-
case 2:
|
|
371
|
-
if (!(i < fileDatas.length)) return [3 /*break*/, 20];
|
|
372
|
-
fileData = fileDatas[i];
|
|
373
|
-
if (!fileData) return [3 /*break*/, 18];
|
|
374
|
-
_a.label = 3;
|
|
375
|
-
case 3:
|
|
376
|
-
_a.trys.push([3, 16, , 17]);
|
|
377
|
-
if (!fileData.startsWith('data:application/pdf;base64,')) return [3 /*break*/, 6];
|
|
378
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.load(fileData, { updateMetadata: false, parseSpeed: pdf_lib_1.ParseSpeeds.Fastest, ignoreEncryption: true })];
|
|
379
|
-
case 4:
|
|
380
|
-
pdf = _a.sent();
|
|
381
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
382
|
-
case 5:
|
|
383
|
-
copiedPages = _a.sent();
|
|
384
|
-
copiedPages.forEach(function (page) {
|
|
385
|
-
mergedPdf.addPage(page);
|
|
386
|
-
});
|
|
387
|
-
return [3 /*break*/, 15];
|
|
388
|
-
case 6:
|
|
389
|
-
if (!(fileData.startsWith('data:image/jpeg;base64,/9j/') || fileData.startsWith('data:image/png;base64,/9j/'))) return [3 /*break*/, 10];
|
|
390
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
391
|
-
case 7:
|
|
392
|
-
pdf = _a.sent();
|
|
393
|
-
return [4 /*yield*/, pdf.embedJpg(fileData)];
|
|
394
|
-
case 8:
|
|
395
|
-
img = _a.sent();
|
|
396
|
-
page = pdf.addPage();
|
|
397
|
-
imgDim = img.scaleToFit(page.getWidth() * 0.75, page.getHeight() * 0.75);
|
|
398
|
-
page.drawImage(img, {
|
|
399
|
-
x: page.getWidth() / 2 - imgDim.width / 2,
|
|
400
|
-
y: page.getHeight() / 2 - imgDim.height / 2,
|
|
401
|
-
width: imgDim.width,
|
|
402
|
-
height: imgDim.height,
|
|
403
|
-
});
|
|
404
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
405
|
-
case 9:
|
|
406
|
-
copiedPages = _a.sent();
|
|
407
|
-
copiedPages.forEach(function (page) {
|
|
408
|
-
mergedPdf.addPage(page);
|
|
409
|
-
});
|
|
410
|
-
return [3 /*break*/, 15];
|
|
411
|
-
case 10:
|
|
412
|
-
if (!fileData.startsWith('data:image/png;base64,iVBOR')) return [3 /*break*/, 14];
|
|
413
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
414
|
-
case 11:
|
|
415
|
-
pdf = _a.sent();
|
|
416
|
-
return [4 /*yield*/, pdf.embedPng(fileData)];
|
|
417
|
-
case 12:
|
|
418
|
-
img = _a.sent();
|
|
419
|
-
page = pdf.addPage();
|
|
420
|
-
imgDim = img.scaleToFit(page.getWidth() * 0.75, page.getHeight() * 0.75);
|
|
421
|
-
page.drawImage(img, {
|
|
422
|
-
x: page.getWidth() / 2 - imgDim.width / 2,
|
|
423
|
-
y: page.getHeight() / 2 - imgDim.height / 2,
|
|
424
|
-
width: imgDim.width,
|
|
425
|
-
height: imgDim.height,
|
|
426
|
-
});
|
|
427
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
428
|
-
case 13:
|
|
429
|
-
copiedPages = _a.sent();
|
|
430
|
-
copiedPages.forEach(function (page) {
|
|
431
|
-
mergedPdf.addPage(page);
|
|
432
|
-
});
|
|
433
|
-
return [3 /*break*/, 15];
|
|
434
|
-
case 14:
|
|
435
|
-
console.log('Error - unsupported!!', fileData.slice(0, 60));
|
|
436
|
-
_a.label = 15;
|
|
437
|
-
case 15: return [3 /*break*/, 17];
|
|
438
|
-
case 16:
|
|
439
|
-
error_1 = _a.sent();
|
|
440
|
-
console.log('Error processing fileData:', fileData.slice(0, 60), error_1);
|
|
441
|
-
return [3 /*break*/, 17];
|
|
442
|
-
case 17: return [3 /*break*/, 19];
|
|
443
|
-
case 18:
|
|
444
|
-
console.log('Error - no filedata!!', fileData);
|
|
445
|
-
_a.label = 19;
|
|
446
|
-
case 19:
|
|
447
|
-
i++;
|
|
448
|
-
return [3 /*break*/, 2];
|
|
449
|
-
case 20: return [4 /*yield*/, mergedPdf.save()];
|
|
450
|
-
case 21:
|
|
451
|
-
mergedPDFUint8 = _a.sent();
|
|
452
|
-
b64PDF = 'data:application/pdf;base64,' + Buffer.from(mergedPDFUint8).toString('base64');
|
|
453
|
-
this.callMethodInternal('uploadFileAndSave', fileName, b64PDF, (4 * Math.ceil(b64PDF.length / 3)), -1, fileType, false, function (errUp, resUp) {
|
|
454
|
-
resolve(resUp);
|
|
455
|
-
});
|
|
456
|
-
return [2 /*return*/];
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
}); });
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
_this.callMethodInternal('insertErrorLog', 'PDF Merge - getSignedUrls', [
|
|
463
|
-
fileKeys,
|
|
464
|
-
errSigneds
|
|
465
|
-
]);
|
|
466
|
-
reject(errSigneds);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
},
|
|
472
|
-
mergePDFResolveNoSave: {
|
|
473
|
-
check: new simpl_schema_1.default({
|
|
474
|
-
fileKeys: {
|
|
475
|
-
type: Array
|
|
476
|
-
},
|
|
477
|
-
'fileKeys.$': {
|
|
478
|
-
type: String
|
|
479
|
-
}
|
|
480
|
-
}),
|
|
481
|
-
function: function (fileKeys) {
|
|
482
|
-
var _this = this;
|
|
483
|
-
return new Promise(function (resolve, reject) {
|
|
484
|
-
_this.callMethodInternal('getSignedUrls', fileKeys, 900, function (errSigneds, resSigneds) {
|
|
485
|
-
if (resSigneds && resSigneds.length) {
|
|
486
|
-
var promises_2 = [];
|
|
487
|
-
resSigneds.forEach(function (signedUrl) {
|
|
488
|
-
promises_2.push(_this.callMethodInternal('getDataURIfromURL', signedUrl));
|
|
489
|
-
});
|
|
490
|
-
Promise.all(promises_2).then(function (fileDatas) { return __awaiter(_this, void 0, void 0, function () {
|
|
491
|
-
var mergedPdf, i, fileData, pdf, copiedPages, pdf, img, page, imgDim, copiedPages, pdf, img, page, imgDim, copiedPages, error_2, mergedPDFUint8, b64PDF;
|
|
492
|
-
return __generator(this, function (_a) {
|
|
493
|
-
switch (_a.label) {
|
|
494
|
-
case 0: return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
495
|
-
case 1:
|
|
496
|
-
mergedPdf = _a.sent();
|
|
497
|
-
i = 0;
|
|
498
|
-
_a.label = 2;
|
|
499
|
-
case 2:
|
|
500
|
-
if (!(i < fileDatas.length)) return [3 /*break*/, 20];
|
|
501
|
-
fileData = fileDatas[i];
|
|
502
|
-
if (!fileData) return [3 /*break*/, 18];
|
|
503
|
-
_a.label = 3;
|
|
504
|
-
case 3:
|
|
505
|
-
_a.trys.push([3, 16, , 17]);
|
|
506
|
-
if (!fileData.startsWith('data:application/pdf;base64,')) return [3 /*break*/, 6];
|
|
507
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.load(fileData, { updateMetadata: false, parseSpeed: pdf_lib_1.ParseSpeeds.Fastest, ignoreEncryption: true })];
|
|
508
|
-
case 4:
|
|
509
|
-
pdf = _a.sent();
|
|
510
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
511
|
-
case 5:
|
|
512
|
-
copiedPages = _a.sent();
|
|
513
|
-
copiedPages.forEach(function (page) {
|
|
514
|
-
mergedPdf.addPage(page);
|
|
515
|
-
});
|
|
516
|
-
return [3 /*break*/, 15];
|
|
517
|
-
case 6:
|
|
518
|
-
if (!(fileData.startsWith('data:image/jpeg;base64,/9j/') || fileData.startsWith('data:image/png;base64,/9j/'))) return [3 /*break*/, 10];
|
|
519
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
520
|
-
case 7:
|
|
521
|
-
pdf = _a.sent();
|
|
522
|
-
return [4 /*yield*/, pdf.embedJpg(fileData)];
|
|
523
|
-
case 8:
|
|
524
|
-
img = _a.sent();
|
|
525
|
-
page = pdf.addPage();
|
|
526
|
-
imgDim = img.scaleToFit(page.getWidth() * 0.75, page.getHeight() * 0.75);
|
|
527
|
-
page.drawImage(img, {
|
|
528
|
-
x: page.getWidth() / 2 - imgDim.width / 2,
|
|
529
|
-
y: page.getHeight() / 2 - imgDim.height / 2,
|
|
530
|
-
width: imgDim.width,
|
|
531
|
-
height: imgDim.height,
|
|
532
|
-
});
|
|
533
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
534
|
-
case 9:
|
|
535
|
-
copiedPages = _a.sent();
|
|
536
|
-
copiedPages.forEach(function (page) {
|
|
537
|
-
mergedPdf.addPage(page);
|
|
538
|
-
});
|
|
539
|
-
return [3 /*break*/, 15];
|
|
540
|
-
case 10:
|
|
541
|
-
if (!fileData.startsWith('data:image/png;base64,iVBOR')) return [3 /*break*/, 14];
|
|
542
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
543
|
-
case 11:
|
|
544
|
-
pdf = _a.sent();
|
|
545
|
-
return [4 /*yield*/, pdf.embedPng(fileData)];
|
|
546
|
-
case 12:
|
|
547
|
-
img = _a.sent();
|
|
548
|
-
page = pdf.addPage();
|
|
549
|
-
imgDim = img.scaleToFit(page.getWidth() * 0.75, page.getHeight() * 0.75);
|
|
550
|
-
page.drawImage(img, {
|
|
551
|
-
x: page.getWidth() / 2 - imgDim.width / 2,
|
|
552
|
-
y: page.getHeight() / 2 - imgDim.height / 2,
|
|
553
|
-
width: imgDim.width,
|
|
554
|
-
height: imgDim.height,
|
|
555
|
-
});
|
|
556
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
557
|
-
case 13:
|
|
558
|
-
copiedPages = _a.sent();
|
|
559
|
-
copiedPages.forEach(function (page) {
|
|
560
|
-
mergedPdf.addPage(page);
|
|
561
|
-
});
|
|
562
|
-
return [3 /*break*/, 15];
|
|
563
|
-
case 14:
|
|
564
|
-
console.log('Error - unsupported!!', fileData.slice(0, 60));
|
|
565
|
-
_a.label = 15;
|
|
566
|
-
case 15: return [3 /*break*/, 17];
|
|
567
|
-
case 16:
|
|
568
|
-
error_2 = _a.sent();
|
|
569
|
-
console.log('Error processing fileData:', fileData.slice(0, 60), error_2);
|
|
570
|
-
return [3 /*break*/, 17];
|
|
571
|
-
case 17: return [3 /*break*/, 19];
|
|
572
|
-
case 18:
|
|
573
|
-
console.log('Error - no filedata!!', fileData);
|
|
574
|
-
_a.label = 19;
|
|
575
|
-
case 19:
|
|
576
|
-
i++;
|
|
577
|
-
return [3 /*break*/, 2];
|
|
578
|
-
case 20: return [4 /*yield*/, mergedPdf.save()];
|
|
579
|
-
case 21:
|
|
580
|
-
mergedPDFUint8 = _a.sent();
|
|
581
|
-
b64PDF = 'data:application/pdf;base64,' + Buffer.from(mergedPDFUint8).toString('base64');
|
|
582
|
-
resolve(b64PDF);
|
|
583
|
-
return [2 /*return*/];
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
}); });
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
_this.callMethodInternal('insertErrorLog', 'PDF Merge - getSignedUrls', [
|
|
590
|
-
fileKeys,
|
|
591
|
-
errSigneds
|
|
592
|
-
]);
|
|
593
|
-
reject(errSigneds);
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
},
|
|
599
|
-
mergePDFResolveHtml: {
|
|
600
|
-
check: new simpl_schema_1.default({
|
|
601
|
-
htmls: {
|
|
602
|
-
type: Array
|
|
603
|
-
},
|
|
604
|
-
'htmls.$': {
|
|
605
|
-
type: String
|
|
606
|
-
},
|
|
607
|
-
fileName: {
|
|
608
|
-
type: String
|
|
609
|
-
},
|
|
610
|
-
fileType: {
|
|
611
|
-
type: String,
|
|
612
|
-
optional: true
|
|
613
|
-
},
|
|
614
|
-
save: {
|
|
615
|
-
type: Boolean,
|
|
616
|
-
optional: true
|
|
617
|
-
}
|
|
618
|
-
}),
|
|
619
|
-
function: function (htmls, fileName, fileType, save) {
|
|
620
|
-
var _this = this;
|
|
621
|
-
if (save === void 0) { save = true; }
|
|
622
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
623
|
-
var mergedPdf, i, fileData, pdf, copiedPages, pdf, img, page, imgDim, copiedPages, pdf, img, page, imgDim, copiedPages, error_3, mergedPDFUint8, b64PDF;
|
|
624
|
-
return __generator(this, function (_a) {
|
|
625
|
-
switch (_a.label) {
|
|
626
|
-
case 0: return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
627
|
-
case 1:
|
|
628
|
-
mergedPdf = _a.sent();
|
|
629
|
-
i = 0;
|
|
630
|
-
_a.label = 2;
|
|
631
|
-
case 2:
|
|
632
|
-
if (!(i < htmls.length)) return [3 /*break*/, 20];
|
|
633
|
-
fileData = htmls[i];
|
|
634
|
-
if (!fileData) return [3 /*break*/, 18];
|
|
635
|
-
_a.label = 3;
|
|
636
|
-
case 3:
|
|
637
|
-
_a.trys.push([3, 16, , 17]);
|
|
638
|
-
if (!fileData.startsWith('data:application/pdf;base64,')) return [3 /*break*/, 6];
|
|
639
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.load(fileData, { updateMetadata: false, parseSpeed: pdf_lib_1.ParseSpeeds.Fastest, ignoreEncryption: true })];
|
|
640
|
-
case 4:
|
|
641
|
-
pdf = _a.sent();
|
|
642
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
643
|
-
case 5:
|
|
644
|
-
copiedPages = _a.sent();
|
|
645
|
-
copiedPages.forEach(function (page) {
|
|
646
|
-
mergedPdf.addPage(page);
|
|
647
|
-
});
|
|
648
|
-
return [3 /*break*/, 15];
|
|
649
|
-
case 6:
|
|
650
|
-
if (!(fileData.startsWith('data:image/jpeg;base64,/9j/') || fileData.startsWith('data:image/png;base64,/9j/'))) return [3 /*break*/, 10];
|
|
651
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
652
|
-
case 7:
|
|
653
|
-
pdf = _a.sent();
|
|
654
|
-
return [4 /*yield*/, pdf.embedJpg(fileData)];
|
|
655
|
-
case 8:
|
|
656
|
-
img = _a.sent();
|
|
657
|
-
page = pdf.addPage();
|
|
658
|
-
imgDim = img.scaleToFit(page.getWidth() * 0.75, page.getHeight() * 0.75);
|
|
659
|
-
page.drawImage(img, {
|
|
660
|
-
x: page.getWidth() / 2 - imgDim.width / 2,
|
|
661
|
-
y: page.getHeight() / 2 - imgDim.height / 2,
|
|
662
|
-
width: imgDim.width,
|
|
663
|
-
height: imgDim.height,
|
|
664
|
-
});
|
|
665
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
666
|
-
case 9:
|
|
667
|
-
copiedPages = _a.sent();
|
|
668
|
-
copiedPages.forEach(function (page) {
|
|
669
|
-
mergedPdf.addPage(page);
|
|
670
|
-
});
|
|
671
|
-
return [3 /*break*/, 15];
|
|
672
|
-
case 10:
|
|
673
|
-
if (!fileData.startsWith('data:image/png;base64,iVBOR')) return [3 /*break*/, 14];
|
|
674
|
-
return [4 /*yield*/, pdf_lib_1.PDFDocument.create()];
|
|
675
|
-
case 11:
|
|
676
|
-
pdf = _a.sent();
|
|
677
|
-
return [4 /*yield*/, pdf.embedPng(fileData)];
|
|
678
|
-
case 12:
|
|
679
|
-
img = _a.sent();
|
|
680
|
-
page = pdf.addPage();
|
|
681
|
-
imgDim = img.scaleToFit(page.getWidth() * 0.75, page.getHeight() * 0.75);
|
|
682
|
-
page.drawImage(img, {
|
|
683
|
-
x: page.getWidth() / 2 - imgDim.width / 2,
|
|
684
|
-
y: page.getHeight() / 2 - imgDim.height / 2,
|
|
685
|
-
width: imgDim.width,
|
|
686
|
-
height: imgDim.height,
|
|
687
|
-
});
|
|
688
|
-
return [4 /*yield*/, mergedPdf.copyPages(pdf, pdf.getPageIndices())];
|
|
689
|
-
case 13:
|
|
690
|
-
copiedPages = _a.sent();
|
|
691
|
-
copiedPages.forEach(function (page) {
|
|
692
|
-
mergedPdf.addPage(page);
|
|
693
|
-
});
|
|
694
|
-
return [3 /*break*/, 15];
|
|
695
|
-
case 14:
|
|
696
|
-
console.log('Error - unsupported!!', fileData.slice(0, 60));
|
|
697
|
-
_a.label = 15;
|
|
698
|
-
case 15: return [3 /*break*/, 17];
|
|
699
|
-
case 16:
|
|
700
|
-
error_3 = _a.sent();
|
|
701
|
-
console.log('Error processing fileData:', fileData.slice(0, 60), error_3);
|
|
702
|
-
return [3 /*break*/, 17];
|
|
703
|
-
case 17: return [3 /*break*/, 19];
|
|
704
|
-
case 18:
|
|
705
|
-
console.log('Error - no filedata!!', fileData);
|
|
706
|
-
_a.label = 19;
|
|
707
|
-
case 19:
|
|
708
|
-
i++;
|
|
709
|
-
return [3 /*break*/, 2];
|
|
710
|
-
case 20: return [4 /*yield*/, mergedPdf.save()];
|
|
711
|
-
case 21:
|
|
712
|
-
mergedPDFUint8 = _a.sent();
|
|
713
|
-
b64PDF = 'data:application/pdf;base64,' + Buffer.from(mergedPDFUint8).toString('base64');
|
|
714
|
-
if (save) {
|
|
715
|
-
this.callMethodInternal('uploadFileAndSave', fileName, b64PDF, (4 * Math.ceil(b64PDF.length / 3)), -1, fileType, false, function (errUp, resUp) {
|
|
716
|
-
resolve(resUp);
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
else {
|
|
720
|
-
resolve(b64PDF);
|
|
721
|
-
}
|
|
722
|
-
return [2 /*return*/];
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
}); });
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
exports.loadPDFMethods = loadPDFMethods;
|
|
731
|
-
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(t,o,s,l){return new(s=s||Promise)(function(n,e){function a(t){try{i(l.next(t))}catch(t){e(t)}}function r(t){try{i(l.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?n(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(a,r)}i((l=l.apply(t,o||[])).next())})},__generator=this&&this.__generator||function(a,r){var i,o,s,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},f={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(f[Symbol.iterator]=function(){return this}),f;function t(n){return function(t){var e=[n,t];if(i)throw new TypeError("Generator is already executing.");for(;l=f&&e[f=0]?0:l;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,(e=s?[2&e[0],s.value]:e)[0]){case 0:case 1:s=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,o=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(s=0<(s=l.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3]))l.label=e[1];else if(6===e[0]&&l.label<s[1])l.label=s[1],s=e;else{if(!(s&&l.label<s[2])){s[2]&&l.ops.pop(),l.trys.pop();continue}l.label=s[2],l.ops.push(e)}}e=r.call(a,l)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}},fs=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadPDFMethods=void 0,require("fs")),simpl_schema_1=require("simpl-schema"),pdf_lib_1=require("pdf-lib"),puppeteer=require("puppeteer"),path=require("path"),pdfCnt=0;function loadPDFMethods(t){t.methods({generatePDF:{check:new simpl_schema_1.default({html:{type:String},fileName:{type:String},orientation:{type:String,optional:!0},fontSize:{type:String,optional:!0},upload:{type:Boolean,optional:!0},uploadFileOrder:{type:Number,optional:!0},uploadFileType:{type:String,optional:!0}}),function:function(p,u,g,h,b,m,w){var t=this;return void 0===g&&(g="portrait"),void 0===h&&(h="12px"),void 0===b&&(b=!1),void 0===m&&(m=-1),void 0===w&&(w=""),new Promise(function(c,d){return __awaiter(t,void 0,void 0,function(){var e,n,a,r,i,o,s,l,f=this;return __generator(this,function(t){switch(t.label){case 0:return a=["--disable-dev-shm-usage","--no-sandbox","--disable-setuid-sandbox","--disable-accelerated-2d-canvas","--disable-gpu","--allow-file-access-from-files","--enable-local-file-accesses","--font-render-hinting=none"],[4,puppeteer.launch({headless:"new",devtools:!1,ignoreHTTPSErrors:!0,args:a,ignoreDefaultArgs:["--disable-extensions"]})];case 1:return[4,(e=t.sent()).newPage()];case 2:return n=t.sent(),a="",a=fs.existsSync(path.join(__dirname,"../private/fonts/dejavuserif.woff"))?path.join(__dirname,"../private/fonts/"):fs.existsSync(path.join(this.clientDir,"./private/fonts/dejavuserif.woff"))?path.join(this.clientDir,"./private/fonts/"):"/usr/share/fonts/dejavu/",s="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif.woff").buffer).toString("base64"),r="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif-bold.woff").buffer).toString("base64"),i="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif-italic.woff").buffer).toString("base64"),o="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif-bolditalic.woff").buffer).toString("base64"),s='\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<style type="text/css">\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: \'Dejavu Serif\';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url("'+s+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\""+r+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\""+i+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\""+o+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tbody {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-size: "+(h||"12px")+";\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.row {\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\t\t\tflex-wrap: wrap;\n\t\t\t\t\t\t\t\t\t-webkit-flex-wrap: wrap;\n\t\t\t\t\t\t\t\t\tpage-break-inside: avoid !important;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.page-break {\n\t\t\t\t\t\t\t\t\tpage-break-before: always !important;\n\t\t\t\t\t\t\t\t\tpadding-top: 1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\tpadding : 2px;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell-no-padding {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: center;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-left {\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-start;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-right {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-end;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.box {\n\t\t\t\t\t\t\t\t\tborder: 1px solid black;\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.boxNoBorder {\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpre {\n\t\t\t\t\t\t\t\t\twhite-space: pre-wrap; /* css-3 */\n\t\t\t\t\t\t\t\t\twhite-space: -moz-pre-wrap; /* Mozilla, since 1999 */\n\t\t\t\t\t\t\t\t\twhite-space: -pre-wrap; /* Opera 4-6 */\n\t\t\t\t\t\t\t\t\twhite-space: -o-pre-wrap; /* Opera 7 */\n\t\t\t\t\t\t\t\t\tword-wrap: break-word; /* Internet Explorer 5.5+ */\n\t\t\t\t\t\t\t\t\tfont-size: 12px;\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif'; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t"+p.replace(new RegExp("flex-basis:","g"),"-webkit-flex-basis:").replace(new RegExp("flex:","g"),"-webkit-flex:")+"</body>",[4,n.setContent(s,{waitUntil:["domcontentloaded","load","networkidle0"]})];case 3:return t.sent(),[4,n.evaluateHandle("document.fonts.ready")];case 4:return t.sent(),l=pdfCnt+++"-"+u.replace(new RegExp(/[^0-9\.a-zA-Z]/g),""),[4,n.pdf({scale:1,landscape:"portrait"!==g,format:"letter",margin:{top:"1cm",bottom:"1cm",left:"1cm",right:"1cm"},printBackground:!0,displayHeaderFooter:!0,headerTemplate:"\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t#header { \n\t\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t",footerTemplate:'\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t#footer { \n\t\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important;\n\t\t\t\t\t\t\t\t\tfont-size: 10px;\n\t\t\t\t\t\t\t\t\tfont-family: san-serif;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<div style="padding-bottom: 2px; padding-right: 15px; text-align: right; width: 100%;">\n\t\t\t\t\t\t\t\tPage <span class="pageNumber"></span> of <span class="totalPages"></span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t',path:path.join(__dirname,l),timeout:0})];case 5:return t.sent(),[4,e.close()];case 6:return t.sent(),fs.existsSync(path.join(__dirname,l))?fs.readFile(path.join(__dirname,l),function(t,e){t?d("No file"):(fs.unlinkSync(path.join(__dirname,l)),b?(t="data:application/pdf;base64,"+Buffer.from(e).toString("base64"),f.callMethodInternal("uploadFileAndSave",u,t,4*Math.ceil(t.length/3),null!==m?m:-1,w,!1,function(t,e){t?d(t):c(e)})):c("data:application/pdf;base64,"+Buffer.from(e).toString("base64")))}):(d("No tmp file"),console.log("No tmp file ",l)),[2]}})})})}},generatePDFNoPageNumber:{check:new simpl_schema_1.default({html:{type:String},fileName:{type:String},orientation:{type:String,optional:!0},fontSize:{type:String,optional:!0},upload:{type:Boolean,optional:!0},uploadFileOrder:{type:Number,optional:!0},uploadFileType:{type:String,optional:!0}}),function:function(p,u,g,h,b,m,w){var t=this;return void 0===g&&(g="portrait"),void 0===h&&(h="12px"),void 0===b&&(b=!1),void 0===m&&(m=-1),void 0===w&&(w=""),new Promise(function(c,d){return __awaiter(t,void 0,void 0,function(){var e,n,a,r,i,o,s,l,f=this;return __generator(this,function(t){switch(t.label){case 0:return a=["--disable-dev-shm-usage","--no-sandbox","--disable-setuid-sandbox","--disable-accelerated-2d-canvas","--disable-gpu","--allow-file-access-from-files","--enable-local-file-accesses","--font-render-hinting=none"],[4,puppeteer.launch({headless:"new",devtools:!1,ignoreHTTPSErrors:!0,args:a,ignoreDefaultArgs:["--disable-extensions"]})];case 1:return[4,(e=t.sent()).newPage()];case 2:return n=t.sent(),a="",a=fs.existsSync(path.join(__dirname,"../private/fonts/dejavuserif.woff"))?path.join(__dirname,"../private/fonts/"):fs.existsSync(path.join(this.clientDir,"./private/fonts/dejavuserif.woff"))?path.join(this.clientDir,"./private/fonts/"):"/usr/share/fonts/dejavu/",s="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif.woff").buffer).toString("base64"),r="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif-bold.woff").buffer).toString("base64"),i="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif-italic.woff").buffer).toString("base64"),o="data:application/font-woff;base64,"+Buffer.from(fs.readFileSync(a+"dejavuserif-bolditalic.woff").buffer).toString("base64"),s='\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<style type="text/css">\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: \'Dejavu Serif\';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url("'+s+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\""+r+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\""+i+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif';\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\""+o+"\") format('woff');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tbody {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-size: "+(h||"12px")+";\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.row {\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\t\t\tflex-wrap: wrap;\n\t\t\t\t\t\t\t\t\t-webkit-flex-wrap: wrap;\n\t\t\t\t\t\t\t\t\tpage-break-inside: avoid !important;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.page-break {\n\t\t\t\t\t\t\t\t\tpage-break-before: always !important;\n\t\t\t\t\t\t\t\t\tpadding-top: 1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\tpadding : 2px;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell-no-padding {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: center;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-left {\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-start;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-right {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-end;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.box {\n\t\t\t\t\t\t\t\t\tborder: 1px solid black;\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.boxNoBorder {\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpre {\n\t\t\t\t\t\t\t\t\twhite-space: pre-wrap; /* css-3 */\n\t\t\t\t\t\t\t\t\twhite-space: -moz-pre-wrap; /* Mozilla, since 1999 */\n\t\t\t\t\t\t\t\t\twhite-space: -pre-wrap; /* Opera 4-6 */\n\t\t\t\t\t\t\t\t\twhite-space: -o-pre-wrap; /* Opera 7 */\n\t\t\t\t\t\t\t\t\tword-wrap: break-word; /* Internet Explorer 5.5+ */\n\t\t\t\t\t\t\t\t\tfont-size: 12px;\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif'; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<meta charset=\"UTF-8\">\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t"+p.replace(new RegExp("flex-basis:","g"),"-webkit-flex-basis:").replace(new RegExp("flex:","g"),"-webkit-flex:")+"</body>",[4,n.setContent(s,{waitUntil:["domcontentloaded","load","networkidle0"]})];case 3:return t.sent(),[4,n.evaluateHandle("document.fonts.ready")];case 4:return t.sent(),l=pdfCnt+++"-"+u.replace(new RegExp(/[^0-9\.a-zA-Z]/g),""),[4,n.pdf({scale:1,landscape:"portrait"!==g,format:"letter",margin:{top:"1cm",bottom:"1cm",left:"1cm",right:"1cm"},printBackground:!0,displayHeaderFooter:!0,headerTemplate:"\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t#header { \n\t\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t",footerTemplate:'\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t#footer { \n\t\t\t\t\t\t\t\tpadding: 0 0 10px 10px !important;\n\t\t\t\t\t\t\t\tfont-size: 10px;\n\t\t\t\t\t\t\t\tfont-family: san-serif;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t\t<div style="padding-bottom: 2px; padding-right: 15px; text-align: right; width: 100%;">\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t',path:path.join(__dirname,l),timeout:0})];case 5:return t.sent(),[4,e.close()];case 6:return t.sent(),fs.existsSync(path.join(__dirname,l))?fs.readFile(path.join(__dirname,l),function(t,e){t?d("No file"):(fs.unlinkSync(path.join(__dirname,l)),b?(t="data:application/pdf;base64,"+Buffer.from(e).toString("base64"),f.callMethodInternal("uploadFileAndSave",u,t,4*Math.ceil(t.length/3),null!==m?m:-1,w,!1,function(t,e){t?d(t):c(e)})):c("data:application/pdf;base64,"+Buffer.from(e).toString("base64")))}):(d("No tmp file"),console.log("No tmp file ",l)),[2]}})})})}},mergePDFResolve:{check:new simpl_schema_1.default({fileKeys:{type:Array},"fileKeys.$":{type:String},fileName:{type:String},fileType:{type:String,optional:!0}}),function:function(r,p,u){var i=this;return new Promise(function(d,a){i.callMethodInternal("getSignedUrls",r,900,function(t,e){var n;e&&e.length?(n=[],e.forEach(function(t){n.push(i.callMethodInternal("getDataURIfromURL",t))}),Promise.all(n).then(function(c){return __awaiter(i,void 0,void 0,function(){var e,n,a,r,i,o,s,l,f;return __generator(this,function(t){switch(t.label){case 0:return[4,pdf_lib_1.PDFDocument.create()];case 1:e=t.sent(),n=0,t.label=2;case 2:if(!(n<c.length))return[3,20];if(!(a=c[n]))return[3,18];t.label=3;case 3:return(t.trys.push([3,16,,17]),a.startsWith("data:application/pdf;base64,"))?[4,pdf_lib_1.PDFDocument.load(a,{updateMetadata:!1,parseSpeed:pdf_lib_1.ParseSpeeds.Fastest,ignoreEncryption:!0})]:[3,6];case 4:return r=t.sent(),[4,e.copyPages(r,r.getPageIndices())];case 5:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 6:return a.startsWith("data:image/jpeg;base64,/9j/")||a.startsWith("data:image/png;base64,/9j/")?[4,pdf_lib_1.PDFDocument.create()]:[3,10];case 7:return[4,(r=t.sent()).embedJpg(a)];case 8:return i=t.sent(),o=r.addPage(),s=i.scaleToFit(.75*o.getWidth(),.75*o.getHeight()),o.drawImage(i,{x:o.getWidth()/2-s.width/2,y:o.getHeight()/2-s.height/2,width:s.width,height:s.height}),[4,e.copyPages(r,r.getPageIndices())];case 9:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 10:return a.startsWith("data:image/png;base64,iVBOR")?[4,pdf_lib_1.PDFDocument.create()]:[3,14];case 11:return[4,(r=t.sent()).embedPng(a)];case 12:return i=t.sent(),o=r.addPage(),s=i.scaleToFit(.75*o.getWidth(),.75*o.getHeight()),o.drawImage(i,{x:o.getWidth()/2-s.width/2,y:o.getHeight()/2-s.height/2,width:s.width,height:s.height}),[4,e.copyPages(r,r.getPageIndices())];case 13:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 14:console.log("Error - unsupported!!",a.slice(0,60)),t.label=15;case 15:return[3,17];case 16:return l=t.sent(),console.log("Error processing fileData:",a.slice(0,60),l),[3,17];case 17:return[3,19];case 18:console.log("Error - no filedata!!",a),t.label=19;case 19:return n++,[3,2];case 20:return[4,e.save()];case 21:return l=t.sent(),f="data:application/pdf;base64,"+Buffer.from(l).toString("base64"),this.callMethodInternal("uploadFileAndSave",p,f,4*Math.ceil(f.length/3),-1,u,!1,function(t,e){d(e)}),[2]}})})})):(i.callMethodInternal("insertErrorLog","PDF Merge - getSignedUrls",[r,t]),a(t))})})}},mergePDFResolveNoSave:{check:new simpl_schema_1.default({fileKeys:{type:Array},"fileKeys.$":{type:String}}),function:function(r){var i=this;return new Promise(function(d,a){i.callMethodInternal("getSignedUrls",r,900,function(t,e){var n;e&&e.length?(n=[],e.forEach(function(t){n.push(i.callMethodInternal("getDataURIfromURL",t))}),Promise.all(n).then(function(c){return __awaiter(i,void 0,void 0,function(){var e,n,a,r,i,o,s,l,f;return __generator(this,function(t){switch(t.label){case 0:return[4,pdf_lib_1.PDFDocument.create()];case 1:e=t.sent(),n=0,t.label=2;case 2:if(!(n<c.length))return[3,20];if(!(a=c[n]))return[3,18];t.label=3;case 3:return(t.trys.push([3,16,,17]),a.startsWith("data:application/pdf;base64,"))?[4,pdf_lib_1.PDFDocument.load(a,{updateMetadata:!1,parseSpeed:pdf_lib_1.ParseSpeeds.Fastest,ignoreEncryption:!0})]:[3,6];case 4:return r=t.sent(),[4,e.copyPages(r,r.getPageIndices())];case 5:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 6:return a.startsWith("data:image/jpeg;base64,/9j/")||a.startsWith("data:image/png;base64,/9j/")?[4,pdf_lib_1.PDFDocument.create()]:[3,10];case 7:return[4,(r=t.sent()).embedJpg(a)];case 8:return i=t.sent(),o=r.addPage(),s=i.scaleToFit(.75*o.getWidth(),.75*o.getHeight()),o.drawImage(i,{x:o.getWidth()/2-s.width/2,y:o.getHeight()/2-s.height/2,width:s.width,height:s.height}),[4,e.copyPages(r,r.getPageIndices())];case 9:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 10:return a.startsWith("data:image/png;base64,iVBOR")?[4,pdf_lib_1.PDFDocument.create()]:[3,14];case 11:return[4,(r=t.sent()).embedPng(a)];case 12:return i=t.sent(),o=r.addPage(),s=i.scaleToFit(.75*o.getWidth(),.75*o.getHeight()),o.drawImage(i,{x:o.getWidth()/2-s.width/2,y:o.getHeight()/2-s.height/2,width:s.width,height:s.height}),[4,e.copyPages(r,r.getPageIndices())];case 13:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 14:console.log("Error - unsupported!!",a.slice(0,60)),t.label=15;case 15:return[3,17];case 16:return l=t.sent(),console.log("Error processing fileData:",a.slice(0,60),l),[3,17];case 17:return[3,19];case 18:console.log("Error - no filedata!!",a),t.label=19;case 19:return n++,[3,2];case 20:return[4,e.save()];case 21:return l=t.sent(),f="data:application/pdf;base64,"+Buffer.from(l).toString("base64"),d(f),[2]}})})})):(i.callMethodInternal("insertErrorLog","PDF Merge - getSignedUrls",[r,t]),a(t))})})}},mergePDFResolveHtml:{check:new simpl_schema_1.default({htmls:{type:Array},"htmls.$":{type:String},fileName:{type:String},fileType:{type:String,optional:!0},save:{type:Boolean,optional:!0}}),function:function(d,p,u,g){var e=this;return void 0===g&&(g=!0),new Promise(function(c,t){return __awaiter(e,void 0,void 0,function(){var e,n,a,r,i,o,s,l,f;return __generator(this,function(t){switch(t.label){case 0:return[4,pdf_lib_1.PDFDocument.create()];case 1:e=t.sent(),n=0,t.label=2;case 2:if(!(n<d.length))return[3,20];if(!(a=d[n]))return[3,18];t.label=3;case 3:return(t.trys.push([3,16,,17]),a.startsWith("data:application/pdf;base64,"))?[4,pdf_lib_1.PDFDocument.load(a,{updateMetadata:!1,parseSpeed:pdf_lib_1.ParseSpeeds.Fastest,ignoreEncryption:!0})]:[3,6];case 4:return r=t.sent(),[4,e.copyPages(r,r.getPageIndices())];case 5:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 6:return a.startsWith("data:image/jpeg;base64,/9j/")||a.startsWith("data:image/png;base64,/9j/")?[4,pdf_lib_1.PDFDocument.create()]:[3,10];case 7:return[4,(r=t.sent()).embedJpg(a)];case 8:return i=t.sent(),o=r.addPage(),s=i.scaleToFit(.75*o.getWidth(),.75*o.getHeight()),o.drawImage(i,{x:o.getWidth()/2-s.width/2,y:o.getHeight()/2-s.height/2,width:s.width,height:s.height}),[4,e.copyPages(r,r.getPageIndices())];case 9:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 10:return a.startsWith("data:image/png;base64,iVBOR")?[4,pdf_lib_1.PDFDocument.create()]:[3,14];case 11:return[4,(r=t.sent()).embedPng(a)];case 12:return i=t.sent(),o=r.addPage(),s=i.scaleToFit(.75*o.getWidth(),.75*o.getHeight()),o.drawImage(i,{x:o.getWidth()/2-s.width/2,y:o.getHeight()/2-s.height/2,width:s.width,height:s.height}),[4,e.copyPages(r,r.getPageIndices())];case 13:return t.sent().forEach(function(t){e.addPage(t)}),[3,15];case 14:console.log("Error - unsupported!!",a.slice(0,60)),t.label=15;case 15:return[3,17];case 16:return l=t.sent(),console.log("Error processing fileData:",a.slice(0,60),l),[3,17];case 17:return[3,19];case 18:console.log("Error - no filedata!!",a),t.label=19;case 19:return n++,[3,2];case 20:return[4,e.save()];case 21:return l=t.sent(),f="data:application/pdf;base64,"+Buffer.from(l).toString("base64"),g?this.callMethodInternal("uploadFileAndSave",p,f,4*Math.ceil(f.length/3),-1,u,!1,function(t,e){c(e)}):c(f),[2]}})})})}}})}exports.loadPDFMethods=loadPDFMethods;
|
|
732
2
|
//# sourceMappingURL=pdf.js.map
|