@resolveio/server-lib 5.2.12 → 5.2.14

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.
Files changed (2) hide show
  1. package/methods/pdf.js +129 -129
  2. package/package.json +1 -1
package/methods/pdf.js CHANGED
@@ -71,7 +71,7 @@ function loadPDFMethods(methodManager) {
71
71
  })
72
72
  }
73
73
  });
74
- page.property('content', "\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', 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(\"/usr/share/fonts/dejavu/DejaVuSerif.ttf\");\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', 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(\"/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf\");\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', 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(\"/usr/share/fonts/dejavu/DejaVuSerif-Italic.ttf\");\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', 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(\"/usr/share/fonts/dejavu/DejaVuSerif-BoldItalic.ttf\");\n\t\t\t\t\t\t\t\t}\n\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 : '8px') + ";\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}\n\t\t\t\t\t\t\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\tmargin-bottom: 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: Open Sans; \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>');
74
+ page.property('content', "\n <head>\n <style>\n @font-face {\n font-family: 'Dejavu Serif', serif;\n font-style: normal;\n font-weight: normal;\n src: url(\"/usr/share/fonts/dejavu/DejaVuSerif.ttf\");\n }\n\n @font-face {\n font-family: 'Dejavu Serif', serif;\n font-style: normal;\n font-weight: bold;\n src: url(\"/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf\");\n }\n\n @font-face {\n font-family: 'Dejavu Serif', serif;\n font-style: italic;\n font-weight: normal;\n src: url(\"/usr/share/fonts/dejavu/DejaVuSerif-Italic.ttf\");\n }\n\n @font-face {\n font-family: 'Dejavu Serif', serif;\n font-style: italic;\n font-weight: bold;\n src: url(\"/usr/share/fonts/dejavu/DejaVuSerif-BoldItalic.ttf\");\n }\n\n body {\n font-family: 'Dejavu Serif', serif;\n font-size: " + (fontSize ? fontSize : '8px') + ";\n }\n\n .row {\n display: -webkit-flex;\n display: flex;\n flex-wrap: wrap;\n -webkit-flex-wrap: wrap;\n }\n \n .page-break {\n page-break-before: always !important;\n margin-bottom: 1px;\n }\n\n .cell {\n box-sizing: border-box;\n padding : 2px;\n -webkit-flex: 1;\n word-wrap: break-word;\n }\n\n .cell-no-padding {\n box-sizing: border-box;\n -webkit-flex: 1;\n word-wrap: break-word;\n }\n\n .centered {\n -webkit-justify-content: center;\n -webkit-align-items: center;\n display: -webkit-flex;\n text-align: center;\n }\n\n .centered-left {\n -webkit-align-items: center;\n display: -webkit-flex;\n -webkit-justify-content: flex-start;\n }\n\n .centered-right {\n -webkit-justify-content: flex-end;\n -webkit-align-items: center;\n display: -webkit-flex;\n }\n \n .box {\n border: 1px solid black;\n margin: -1px 0px 0px -1px;\n }\n\n .boxNoBorder {\n margin: -1px 0px 0px -1px;\n }\n\n pre {\n white-space: pre-wrap; /* css-3 */\n white-space: -moz-pre-wrap; /* Mozilla, since 1999 */\n white-space: -pre-wrap; /* Opera 4-6 */\n white-space: -o-pre-wrap; /* Opera 7 */\n word-wrap: break-word; /* Internet Explorer 5.5+ */\n font-size: 12px;\n font-family: Open Sans; \n }\n </style>\n </head>\n <body>\n " + html.replace(new RegExp('flex-basis:', 'g'), '-webkit-flex-basis:').replace(new RegExp('flex:', 'g'), '-webkit-flex:') + '</body>');
75
75
  var tmpFileName = (pdfCnt++) + '-' + fileName;
76
76
  var interval = setInterval(function () {
77
77
  if (requestsArray.length === 0) {
@@ -120,134 +120,6 @@ function loadPDFMethods(methodManager) {
120
120
  });
121
121
  }
122
122
  },
123
- compressBase64AndUploadPDF: {
124
- skipQueue: true,
125
- check: new simpl_schema_1.default({
126
- id_file: {
127
- type: String
128
- },
129
- fileName: {
130
- type: String
131
- },
132
- filePath: {
133
- type: String
134
- },
135
- fileContent: {
136
- type: String
137
- }
138
- }),
139
- function: function (id_file, fileName, filePath, fileContent) {
140
- var _this = this;
141
- return new Promise(function (resolve, reject) {
142
- _this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
143
- //send request
144
- request({
145
- method: 'POST',
146
- url: 'https:' + resCC.url,
147
- headers: {
148
- 'Content-Type': 'application/json'
149
- },
150
- json: {
151
- mode: 'compress',
152
- input: 'base64',
153
- file: fileContent,
154
- filename: fileName,
155
- outputformat: 'pdf',
156
- wait: true,
157
- output: {
158
- 's3': {
159
- 'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
160
- 'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
161
- 'region': _this.serverConfig['AWSREGION'],
162
- 'bucket': _this.serverConfig['AWSBUCKET'],
163
- 'path': filePath
164
- }
165
- }
166
- }
167
- }, function (error, response, body) {
168
- if (!error) {
169
- if (body.output.size) {
170
- file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
171
- resolve();
172
- }
173
- else {
174
- reject('Compressed file has no size, compress failed');
175
- }
176
- }
177
- else {
178
- reject(error);
179
- }
180
- });
181
- }, function (errCC) { return reject(errCC); });
182
- });
183
- }
184
- },
185
- compressPDFOnS3: {
186
- skipQueue: true,
187
- check: new simpl_schema_1.default({
188
- id_file: {
189
- type: String
190
- },
191
- fileName: {
192
- type: String
193
- },
194
- filePath: {
195
- type: String
196
- }
197
- }),
198
- function: function (id_file, fileName, filePath) {
199
- var _this = this;
200
- return new Promise(function (resolve, reject) {
201
- _this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
202
- //send request
203
- request({
204
- method: 'POST',
205
- url: 'https:' + resCC.url,
206
- headers: {
207
- 'Content-Type': 'application/json'
208
- },
209
- json: {
210
- mode: 'compress',
211
- input: {
212
- 's3': {
213
- 'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
214
- 'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
215
- 'region': _this.serverConfig['AWSREGION'],
216
- 'bucket': _this.serverConfig['AWSBUCKET']
217
- }
218
- },
219
- file: filePath,
220
- filename: fileName,
221
- outputformat: 'pdf',
222
- wait: true,
223
- output: {
224
- 's3': {
225
- 'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
226
- 'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
227
- 'region': _this.serverConfig['AWSREGION'],
228
- 'bucket': _this.serverConfig['AWSBUCKET'],
229
- 'path': filePath
230
- }
231
- }
232
- }
233
- }, function (error, response, body) {
234
- if (!error) {
235
- if (body.output.size) {
236
- file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
237
- resolve();
238
- }
239
- else {
240
- reject('Compressed file has no size, compress failed');
241
- }
242
- }
243
- else {
244
- reject(error);
245
- }
246
- });
247
- }, function (errCC) { return reject(errCC); });
248
- });
249
- }
250
- },
251
123
  mergePDF: {
252
124
  skipQueue: true,
253
125
  check: new simpl_schema_1.default({
@@ -441,6 +313,134 @@ function loadPDFMethods(methodManager) {
441
313
  }, function (errCC) { return reject(errCC); });
442
314
  });
443
315
  }
316
+ },
317
+ compressBase64AndUploadPDF: {
318
+ skipQueue: true,
319
+ check: new simpl_schema_1.default({
320
+ id_file: {
321
+ type: String
322
+ },
323
+ fileName: {
324
+ type: String
325
+ },
326
+ filePath: {
327
+ type: String
328
+ },
329
+ fileContent: {
330
+ type: String
331
+ }
332
+ }),
333
+ function: function (id_file, fileName, filePath, fileContent) {
334
+ var _this = this;
335
+ return new Promise(function (resolve, reject) {
336
+ _this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
337
+ //send request
338
+ request({
339
+ method: 'POST',
340
+ url: 'https:' + resCC.url,
341
+ headers: {
342
+ 'Content-Type': 'application/json'
343
+ },
344
+ json: {
345
+ mode: 'compress',
346
+ input: 'base64',
347
+ file: fileContent,
348
+ filename: fileName,
349
+ outputformat: 'pdf',
350
+ wait: true,
351
+ output: {
352
+ 's3': {
353
+ 'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
354
+ 'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
355
+ 'region': _this.serverConfig['AWSREGION'],
356
+ 'bucket': _this.serverConfig['AWSBUCKET'],
357
+ 'path': filePath
358
+ }
359
+ }
360
+ }
361
+ }, function (error, response, body) {
362
+ if (!error) {
363
+ if (body.output.size) {
364
+ file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
365
+ resolve();
366
+ }
367
+ else {
368
+ reject('Compressed file has no size, compress failed');
369
+ }
370
+ }
371
+ else {
372
+ reject(error);
373
+ }
374
+ });
375
+ }, function (errCC) { return reject(errCC); });
376
+ });
377
+ }
378
+ },
379
+ compressPDFOnS3: {
380
+ skipQueue: true,
381
+ check: new simpl_schema_1.default({
382
+ id_file: {
383
+ type: String
384
+ },
385
+ fileName: {
386
+ type: String
387
+ },
388
+ filePath: {
389
+ type: String
390
+ }
391
+ }),
392
+ function: function (id_file, fileName, filePath) {
393
+ var _this = this;
394
+ return new Promise(function (resolve, reject) {
395
+ _this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
396
+ //send request
397
+ request({
398
+ method: 'POST',
399
+ url: 'https:' + resCC.url,
400
+ headers: {
401
+ 'Content-Type': 'application/json'
402
+ },
403
+ json: {
404
+ mode: 'compress',
405
+ input: {
406
+ 's3': {
407
+ 'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
408
+ 'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
409
+ 'region': _this.serverConfig['AWSREGION'],
410
+ 'bucket': _this.serverConfig['AWSBUCKET']
411
+ }
412
+ },
413
+ file: filePath,
414
+ filename: fileName,
415
+ outputformat: 'pdf',
416
+ wait: true,
417
+ output: {
418
+ 's3': {
419
+ 'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
420
+ 'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
421
+ 'region': _this.serverConfig['AWSREGION'],
422
+ 'bucket': _this.serverConfig['AWSBUCKET'],
423
+ 'path': filePath
424
+ }
425
+ }
426
+ }
427
+ }, function (error, response, body) {
428
+ if (!error) {
429
+ if (body.output.size) {
430
+ file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
431
+ resolve();
432
+ }
433
+ else {
434
+ reject('Compressed file has no size, compress failed');
435
+ }
436
+ }
437
+ else {
438
+ reject(error);
439
+ }
440
+ });
441
+ }, function (errCC) { return reject(errCC); });
442
+ });
443
+ }
444
444
  }
445
445
  });
446
446
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "5.2.12",
3
+ "version": "5.2.14",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {