@tstdl/base 0.83.27 → 0.83.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/application/application.js +1 -1
- package/browser/browser-controller.d.ts +26 -0
- package/browser/browser-controller.js +99 -0
- package/browser/browser.service.d.ts +32 -0
- package/browser/browser.service.js +110 -0
- package/browser/index.d.ts +4 -0
- package/browser/index.js +21 -0
- package/browser/page-controller.d.ts +56 -0
- package/browser/page-controller.js +189 -0
- package/browser/pdf-options.d.ts +32 -0
- package/browser/pdf-options.js +134 -0
- package/browser/types.d.ts +3 -0
- package/browser/types.js +16 -0
- package/core.d.ts +1 -1
- package/examples/browser/basic.d.ts +1 -0
- package/examples/browser/basic.js +19 -0
- package/examples/mail/basic.js +11 -3
- package/examples/pdf/basic.js +29 -7
- package/examples/pdf/templates/hello-name.js +10 -2
- package/package.json +3 -3
- package/pdf/pdf.service.d.ts +10 -39
- package/pdf/pdf.service.js +43 -174
- package/pool/pool.js +3 -0
- package/types.d.ts +4 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/stream/finalize-stream.d.ts +22 -1
- package/utils/stream/finalize-stream.js +14 -4
- package/utils/stream/readable-stream-from-promise.d.ts +2 -1
- package/utils/stream/readable-stream-from-promise.js +3 -2
- package/utils/type-guards.d.ts +6 -0
- package/utils/type-guards.js +26 -0
- package/utils/value-or-provider.d.ts +2 -0
- package/utils/value-or-provider.js +30 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pdf_options_exports = {};
|
|
20
|
+
__export(pdf_options_exports, {
|
|
21
|
+
PdfFormat: () => PdfFormat,
|
|
22
|
+
PdfMarginObject: () => PdfMarginObject,
|
|
23
|
+
PdfRenderOptions: () => PdfRenderOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(pdf_options_exports);
|
|
26
|
+
var import_enumeration = require("../schema/schemas/enumeration.js");
|
|
27
|
+
var import_optional = require("../schema/schemas/optional.js");
|
|
28
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
29
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
31
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
32
|
+
else
|
|
33
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
34
|
+
if (d = decorators[i])
|
|
35
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
37
|
+
};
|
|
38
|
+
var __metadata = function(k, v) {
|
|
39
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
40
|
+
return Reflect.metadata(k, v);
|
|
41
|
+
};
|
|
42
|
+
var PdfFormat;
|
|
43
|
+
(function(PdfFormat2) {
|
|
44
|
+
PdfFormat2["Letter"] = "letter";
|
|
45
|
+
PdfFormat2["Legal"] = "legal";
|
|
46
|
+
PdfFormat2["Tabloid"] = "tabloid";
|
|
47
|
+
PdfFormat2["Ledger"] = "ledger";
|
|
48
|
+
PdfFormat2["A0"] = "a0";
|
|
49
|
+
PdfFormat2["A1"] = "a1";
|
|
50
|
+
PdfFormat2["A2"] = "a2";
|
|
51
|
+
PdfFormat2["A3"] = "a3";
|
|
52
|
+
PdfFormat2["A4"] = "a4";
|
|
53
|
+
PdfFormat2["A5"] = "a5";
|
|
54
|
+
PdfFormat2["A6"] = "a6";
|
|
55
|
+
})(PdfFormat || (PdfFormat = {}));
|
|
56
|
+
class PdfMarginObject {
|
|
57
|
+
top;
|
|
58
|
+
bottom;
|
|
59
|
+
right;
|
|
60
|
+
left;
|
|
61
|
+
}
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, import_optional.Optional)([Number, String]),
|
|
64
|
+
__metadata("design:type", Object)
|
|
65
|
+
], PdfMarginObject.prototype, "top", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, import_optional.Optional)([Number, String]),
|
|
68
|
+
__metadata("design:type", Object)
|
|
69
|
+
], PdfMarginObject.prototype, "bottom", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, import_optional.Optional)([Number, String]),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], PdfMarginObject.prototype, "right", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, import_optional.Optional)([Number, String]),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], PdfMarginObject.prototype, "left", void 0);
|
|
78
|
+
class PdfRenderOptions {
|
|
79
|
+
omitDefaultBackground;
|
|
80
|
+
renderBackground;
|
|
81
|
+
landscape;
|
|
82
|
+
format;
|
|
83
|
+
width;
|
|
84
|
+
height;
|
|
85
|
+
scale;
|
|
86
|
+
margin;
|
|
87
|
+
displayHeaderFooter;
|
|
88
|
+
headerTemplate;
|
|
89
|
+
footerTemplate;
|
|
90
|
+
}
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, import_optional.Optional)(),
|
|
93
|
+
__metadata("design:type", Boolean)
|
|
94
|
+
], PdfRenderOptions.prototype, "omitDefaultBackground", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, import_optional.Optional)(),
|
|
97
|
+
__metadata("design:type", Boolean)
|
|
98
|
+
], PdfRenderOptions.prototype, "renderBackground", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, import_optional.Optional)(),
|
|
101
|
+
__metadata("design:type", Boolean)
|
|
102
|
+
], PdfRenderOptions.prototype, "landscape", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, import_enumeration.Enumeration)(PdfFormat, { optional: true }),
|
|
105
|
+
__metadata("design:type", String)
|
|
106
|
+
], PdfRenderOptions.prototype, "format", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, import_optional.Optional)([String, Number]),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], PdfRenderOptions.prototype, "width", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, import_optional.Optional)([String, Number]),
|
|
113
|
+
__metadata("design:type", Object)
|
|
114
|
+
], PdfRenderOptions.prototype, "height", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, import_optional.Optional)(),
|
|
117
|
+
__metadata("design:type", Number)
|
|
118
|
+
], PdfRenderOptions.prototype, "scale", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, import_optional.Optional)([String, Number, PdfMarginObject]),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], PdfRenderOptions.prototype, "margin", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, import_optional.Optional)(),
|
|
125
|
+
__metadata("design:type", Boolean)
|
|
126
|
+
], PdfRenderOptions.prototype, "displayHeaderFooter", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, import_optional.Optional)(),
|
|
129
|
+
__metadata("design:type", String)
|
|
130
|
+
], PdfRenderOptions.prototype, "headerTemplate", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, import_optional.Optional)(),
|
|
133
|
+
__metadata("design:type", String)
|
|
134
|
+
], PdfRenderOptions.prototype, "footerTemplate", void 0);
|
package/browser/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
package/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InjectionToken } from './container/index.js';
|
|
2
2
|
import { AsyncDisposer } from './disposable/async-disposer.js';
|
|
3
3
|
import type { LoggerArgument } from './logger/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { LogLevel, Logger } from './logger/index.js';
|
|
5
5
|
export declare const CORE_LOGGER: InjectionToken<Logger, any>;
|
|
6
6
|
export declare const disposer: AsyncDisposer;
|
|
7
7
|
export declare function connect(name: string, connectFunction: (() => Promise<any>), logger: Logger, maxTries?: number): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_node_fs = require("node:fs");
|
|
3
|
+
var import_application = require("../../application/index.js");
|
|
4
|
+
var import_browser_service = require("../../browser/browser.service.js");
|
|
5
|
+
var import_container = require("../../container/container.js");
|
|
6
|
+
var import_timing = require("../../utils/timing.js");
|
|
7
|
+
async function main() {
|
|
8
|
+
const browserService = await import_container.container.resolveAsync(import_browser_service.BrowserService);
|
|
9
|
+
const browser = await browserService.newBrowser();
|
|
10
|
+
const page = await browser.newPage();
|
|
11
|
+
await page.navigate("https://google.com");
|
|
12
|
+
await page.click("//div[text() = 'Alle ablehnen']", { xpath: true });
|
|
13
|
+
await (0, import_timing.timeout)(1e3);
|
|
14
|
+
const pdf = await page.renderPdf();
|
|
15
|
+
(0, import_node_fs.writeFileSync)("/tmp/pdf.pdf", pdf);
|
|
16
|
+
await page.navigate("file:///tmp/pdf.pdf");
|
|
17
|
+
await browser.waitForClose();
|
|
18
|
+
}
|
|
19
|
+
import_application.Application.run(main);
|
package/examples/mail/basic.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var import_node_path = require("node:path");
|
|
3
|
+
var import_node_url = require("node:url");
|
|
2
4
|
var import_container = require("../../container/index.js");
|
|
3
5
|
var import_nodemailer_mail_client = require("../../mail/clients/nodemailer.mail-client.js");
|
|
4
6
|
var import_mail = require("../../mail/index.js");
|
|
@@ -8,8 +10,14 @@ var import_handlebars_template_renderer = require("../../templates/renderers/han
|
|
|
8
10
|
var import_mjml_template_renderer = require("../../templates/renderers/mjml.template-renderer.js");
|
|
9
11
|
var import_file_template_resolver = require("../../templates/resolvers/file.template-resolver.js");
|
|
10
12
|
var import_config_parser = require("../../utils/config-parser.js");
|
|
11
|
-
var import_node_path = require("node:path");
|
|
12
13
|
var import_core = require("../../core.js");
|
|
14
|
+
const import_meta = {};
|
|
15
|
+
let dirname;
|
|
16
|
+
try {
|
|
17
|
+
dirname = (0, import_node_url.fileURLToPath)(new URL(".", import_meta.url));
|
|
18
|
+
} catch {
|
|
19
|
+
dirname = __dirname;
|
|
20
|
+
}
|
|
13
21
|
(0, import_core.configureTstdl)();
|
|
14
22
|
(0, import_mail.configureMail)({
|
|
15
23
|
clientConfig: {
|
|
@@ -26,8 +34,8 @@ var import_core = require("../../core.js");
|
|
|
26
34
|
templateProvider: import_file_template_provider.FileTemplateProvider,
|
|
27
35
|
templateRenderers: [import_mjml_template_renderer.MjmlTemplateRenderer, import_handlebars_template_renderer.HandlebarsTemplateRenderer]
|
|
28
36
|
});
|
|
29
|
-
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(
|
|
30
|
-
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(
|
|
37
|
+
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(dirname, "templates") });
|
|
38
|
+
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(dirname.replace("/dist", "/source"), "templates") });
|
|
31
39
|
async function test() {
|
|
32
40
|
const service = await import_container.container.resolveAsync(import_mail.MailService);
|
|
33
41
|
const result = await service.sendTemplate("hello-name", { from: (0, import_config_parser.string)("FROM", (0, import_config_parser.string)("USER", "user@example.com")), to: (0, import_config_parser.string)("TO", "user@example.com") }, { name: "Max Mustermann" });
|
package/examples/pdf/basic.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var import_node_fs = require("node:fs");
|
|
3
|
+
var import_node_path = require("node:path");
|
|
4
|
+
var import_node_url = require("node:url");
|
|
2
5
|
var import_application = require("../../application/application.js");
|
|
6
|
+
var import_browser_service = require("../../browser/browser.service.js");
|
|
3
7
|
var import_container = require("../../container/index.js");
|
|
4
8
|
var import_core = require("../../core.js");
|
|
5
9
|
var import_pdf_service = require("../../pdf/pdf.service.js");
|
|
@@ -8,18 +12,36 @@ var import_file_template_provider = require("../../templates/providers/file.temp
|
|
|
8
12
|
var import_handlebars_template_renderer = require("../../templates/renderers/handlebars.template-renderer.js");
|
|
9
13
|
var import_mjml_template_renderer = require("../../templates/renderers/mjml.template-renderer.js");
|
|
10
14
|
var import_file_template_resolver = require("../../templates/resolvers/file.template-resolver.js");
|
|
11
|
-
|
|
15
|
+
const import_meta = {};
|
|
16
|
+
let dirname;
|
|
17
|
+
try {
|
|
18
|
+
dirname = (0, import_node_url.fileURLToPath)(new URL(".", import_meta.url));
|
|
19
|
+
} catch {
|
|
20
|
+
dirname = __dirname;
|
|
21
|
+
}
|
|
12
22
|
(0, import_core.configureTstdl)();
|
|
13
23
|
(0, import_module.configureTemplates)({
|
|
14
24
|
templateProvider: import_file_template_provider.FileTemplateProvider,
|
|
15
25
|
templateResolvers: [import_file_template_resolver.FileTemplateResolver],
|
|
16
26
|
templateRenderers: [import_mjml_template_renderer.MjmlTemplateRenderer, import_handlebars_template_renderer.HandlebarsTemplateRenderer]
|
|
17
27
|
});
|
|
18
|
-
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(
|
|
19
|
-
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(
|
|
20
|
-
async function
|
|
28
|
+
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(dirname, "templates") });
|
|
29
|
+
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(dirname.replace("dist", "source"), "templates") });
|
|
30
|
+
async function main() {
|
|
31
|
+
const browserService = await import_container.container.resolveAsync(import_browser_service.BrowserService);
|
|
21
32
|
const pdfService = await import_container.container.resolveAsync(import_pdf_service.PdfService);
|
|
22
|
-
const
|
|
23
|
-
|
|
33
|
+
const result1 = await pdfService.renderTemplate("hello-name", { name: "Max Mustermann" });
|
|
34
|
+
const result2 = await pdfService.renderUrl("https://google.de");
|
|
35
|
+
console.log(`Resulting PDFs have ${result1.length} and ${result2.length} bytes.`);
|
|
36
|
+
(0, import_node_fs.writeFileSync)("/tmp/template.pdf", result1);
|
|
37
|
+
(0, import_node_fs.writeFileSync)("/tmp/page.pdf", result2);
|
|
38
|
+
const browser = await browserService.newBrowser();
|
|
39
|
+
const page1 = await browser.newPage();
|
|
40
|
+
const page2 = await browser.newPage();
|
|
41
|
+
await Promise.all([
|
|
42
|
+
page1.navigate("file:///tmp/template.pdf"),
|
|
43
|
+
page2.navigate("file:///tmp/page.pdf")
|
|
44
|
+
]);
|
|
45
|
+
await browser.waitForClose();
|
|
24
46
|
}
|
|
25
|
-
import_application.Application.run(
|
|
47
|
+
import_application.Application.run(main);
|
|
@@ -21,17 +21,25 @@ __export(hello_name_exports, {
|
|
|
21
21
|
default: () => hello_name_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(hello_name_exports);
|
|
24
|
+
var import_node_path = require("node:path");
|
|
25
|
+
var import_node_url = require("node:url");
|
|
24
26
|
var import_pdf_service = require("../../../pdf/pdf.service.js");
|
|
25
27
|
var import_file_template_resolver = require("../../../templates/resolvers/file.template-resolver.js");
|
|
26
28
|
var import_string_template_resolver = require("../../../templates/resolvers/string.template-resolver.js");
|
|
27
|
-
|
|
29
|
+
const import_meta = {};
|
|
30
|
+
let dirname;
|
|
31
|
+
try {
|
|
32
|
+
dirname = (0, import_node_url.fileURLToPath)(new URL(".", import_meta.url));
|
|
33
|
+
} catch {
|
|
34
|
+
dirname = __dirname;
|
|
35
|
+
}
|
|
28
36
|
function reverse(value) {
|
|
29
37
|
return value.split("").reverse().join("");
|
|
30
38
|
}
|
|
31
39
|
const template = (0, import_pdf_service.pdfTemplate)("hello-name", {
|
|
32
40
|
body: (0, import_file_template_resolver.fileTemplateField)({
|
|
33
41
|
renderer: "handlebars",
|
|
34
|
-
templateFile: (0, import_node_path.resolve)(
|
|
42
|
+
templateFile: (0, import_node_path.resolve)(dirname.replace("dist", "source"), "hello-name.hbs"),
|
|
35
43
|
options: {
|
|
36
44
|
partials: {
|
|
37
45
|
sometext: (0, import_string_template_resolver.stringTemplateField)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.28",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"luxon": "^3.3",
|
|
22
22
|
"reflect-metadata": "^0.1",
|
|
23
23
|
"rxjs": "^7.8",
|
|
24
|
-
"type-fest": "^3.
|
|
24
|
+
"type-fest": "^3.9"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/chroma-js": "2.4",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@typescript-eslint/parser": "5.59",
|
|
36
36
|
"concurrently": "8.0",
|
|
37
37
|
"esbuild": "0.17",
|
|
38
|
-
"eslint": "8.
|
|
38
|
+
"eslint": "8.39",
|
|
39
39
|
"eslint-import-resolver-typescript": "3.5",
|
|
40
40
|
"eslint-plugin-import": "2.27",
|
|
41
41
|
"tsc-alias": "1.8",
|
package/pdf/pdf.service.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BrowserService } from '../browser/browser.service.js';
|
|
2
|
+
import { PdfRenderOptions } from '../browser/pdf-options.js';
|
|
1
3
|
import type { AfterResolve, Injectable } from '../container/index.js';
|
|
2
4
|
import { afterResolve, type resolveArgumentType } from '../container/index.js';
|
|
3
5
|
import type { AsyncDisposable } from '../disposable/disposable.js';
|
|
@@ -5,39 +7,9 @@ import { disposeAsync } from '../disposable/disposable.js';
|
|
|
5
7
|
import { Logger } from '../logger/index.js';
|
|
6
8
|
import type { TemplateField } from '../templates/index.js';
|
|
7
9
|
import { Template, TemplateService } from '../templates/index.js';
|
|
8
|
-
export declare
|
|
9
|
-
Letter = "letter",
|
|
10
|
-
Legal = "legal",
|
|
11
|
-
Tabloid = "tabloid",
|
|
12
|
-
Ledger = "ledger",
|
|
13
|
-
A0 = "a0",
|
|
14
|
-
A1 = "a1",
|
|
15
|
-
A2 = "a2",
|
|
16
|
-
A3 = "a3",
|
|
17
|
-
A4 = "a4",
|
|
18
|
-
A5 = "a5",
|
|
19
|
-
A6 = "a6"
|
|
20
|
-
}
|
|
21
|
-
export declare class PdfMarginObject {
|
|
22
|
-
top?: number | string;
|
|
23
|
-
bottom?: number | string;
|
|
24
|
-
right?: number | string;
|
|
25
|
-
left?: number | string;
|
|
26
|
-
}
|
|
27
|
-
export declare class PdfRenderOptions {
|
|
10
|
+
export declare class PdfServiceRenderOptions extends PdfRenderOptions {
|
|
28
11
|
language?: string;
|
|
29
|
-
omitDefaultBackground?: boolean;
|
|
30
|
-
renderBackground?: boolean;
|
|
31
|
-
landscape?: boolean;
|
|
32
|
-
format?: PdfFormat;
|
|
33
|
-
width?: string | number;
|
|
34
|
-
height?: string | number;
|
|
35
|
-
scale?: number;
|
|
36
|
-
margin?: string | number | PdfMarginObject;
|
|
37
|
-
displayHeaderFooter?: boolean;
|
|
38
12
|
waitForNetworkIdle?: boolean;
|
|
39
|
-
headerTemplate?: string;
|
|
40
|
-
footerTemplate?: string;
|
|
41
13
|
/**
|
|
42
14
|
* Timeout for closing render context in case something went wrong.
|
|
43
15
|
* @default 60000 (1 minute)
|
|
@@ -61,7 +33,7 @@ export declare class PdfService implements AsyncDisposable, AfterResolve, Inject
|
|
|
61
33
|
private readonly logger;
|
|
62
34
|
private readonly pool;
|
|
63
35
|
readonly [resolveArgumentType]: PdfServiceArgument;
|
|
64
|
-
constructor(templateService: TemplateService, logger: Logger, options?: PdfServiceOptions);
|
|
36
|
+
constructor(templateService: TemplateService, browserService: BrowserService, logger: Logger, options?: PdfServiceOptions);
|
|
65
37
|
[afterResolve](): void;
|
|
66
38
|
[disposeAsync](): Promise<void>;
|
|
67
39
|
dispose(): Promise<void>;
|
|
@@ -71,28 +43,28 @@ export declare class PdfService implements AsyncDisposable, AfterResolve, Inject
|
|
|
71
43
|
* @param options render options
|
|
72
44
|
* @returns pdf stream
|
|
73
45
|
*/
|
|
74
|
-
renderHtmlStream(html: string, options?:
|
|
46
|
+
renderHtmlStream(html: string, options?: PdfServiceRenderOptions): ReadableStream<Uint8Array>;
|
|
75
47
|
/**
|
|
76
48
|
* Renders HTML to pdf
|
|
77
49
|
* @param html html to render
|
|
78
50
|
* @param options render options
|
|
79
51
|
* @returns pdf bytes
|
|
80
52
|
*/
|
|
81
|
-
renderHtml(html: string, options?:
|
|
53
|
+
renderHtml(html: string, options?: PdfServiceRenderOptions): Promise<Uint8Array>;
|
|
82
54
|
/**
|
|
83
55
|
* Renders an url to pdf stream
|
|
84
56
|
* @param url url to load and render
|
|
85
57
|
* @param options render options
|
|
86
58
|
* @returns pdf stream
|
|
87
59
|
*/
|
|
88
|
-
renderUrlStream(url: string, options?:
|
|
60
|
+
renderUrlStream(url: string, options?: PdfServiceRenderOptions): ReadableStream<Uint8Array>;
|
|
89
61
|
/**
|
|
90
62
|
* Renders an url to pdf
|
|
91
63
|
* @param url url to load and render
|
|
92
64
|
* @param options render options
|
|
93
65
|
* @returns pdf bytes
|
|
94
66
|
*/
|
|
95
|
-
renderUrl(url: string, options?:
|
|
67
|
+
renderUrl(url: string, options?: PdfServiceRenderOptions): Promise<Uint8Array>;
|
|
96
68
|
/**
|
|
97
69
|
* Renders a template to pdf
|
|
98
70
|
* @param key template key
|
|
@@ -100,7 +72,7 @@ export declare class PdfService implements AsyncDisposable, AfterResolve, Inject
|
|
|
100
72
|
* @param options additional options, overwrites options specified in template
|
|
101
73
|
* @returns pdf bytes
|
|
102
74
|
*/
|
|
103
|
-
renderTemplateStream<Context extends object>(keyOrTemplate: string | PdfTemplate<Context>, templateContext?: Context, options?:
|
|
75
|
+
renderTemplateStream<Context extends object>(keyOrTemplate: string | PdfTemplate<Context>, templateContext?: Context, options?: PdfServiceRenderOptions): ReadableStream<Uint8Array>;
|
|
104
76
|
/**
|
|
105
77
|
* Renders a template to pdf
|
|
106
78
|
* @param key template key
|
|
@@ -108,9 +80,8 @@ export declare class PdfService implements AsyncDisposable, AfterResolve, Inject
|
|
|
108
80
|
* @param options additional options, overwrites options specified in template
|
|
109
81
|
* @returns pdf bytes
|
|
110
82
|
*/
|
|
111
|
-
renderTemplate(keyOrTemplate: string | PdfTemplate, templateContext?: object, options?:
|
|
83
|
+
renderTemplate(keyOrTemplate: string | PdfTemplate, templateContext?: object, options?: PdfServiceRenderOptions): Promise<Uint8Array>;
|
|
112
84
|
private renderStream;
|
|
113
|
-
private convertOptions;
|
|
114
85
|
}
|
|
115
86
|
export declare function pdfTemplate(name: string, fields: {
|
|
116
87
|
body: TemplateField;
|