@spinajs/templates-pdf 2.0.180 → 2.0.182
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/lib/cjs/config/pdf.d.ts +14 -14
- package/lib/cjs/config/pdf.js +16 -16
- package/lib/cjs/index.d.ts +24 -24
- package/lib/cjs/index.js +125 -125
- package/lib/cjs/index.js.map +1 -1
- package/lib/mjs/config/pdf.d.ts +14 -14
- package/lib/mjs/config/pdf.js +14 -14
- package/lib/mjs/index.d.ts +24 -24
- package/lib/mjs/index.js +119 -119
- package/lib/mjs/index.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +6 -6
package/lib/cjs/config/pdf.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
declare const pdf: {
|
|
2
|
-
templates: {
|
|
3
|
-
pdf: {
|
|
4
|
-
static: {
|
|
5
|
-
port: number;
|
|
6
|
-
};
|
|
7
|
-
args: {
|
|
8
|
-
headless: boolean;
|
|
9
|
-
};
|
|
10
|
-
options: {};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export default pdf;
|
|
1
|
+
declare const pdf: {
|
|
2
|
+
templates: {
|
|
3
|
+
pdf: {
|
|
4
|
+
static: {
|
|
5
|
+
port: number;
|
|
6
|
+
};
|
|
7
|
+
args: {
|
|
8
|
+
headless: boolean;
|
|
9
|
+
};
|
|
10
|
+
options: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default pdf;
|
|
15
15
|
//# sourceMappingURL=pdf.d.ts.map
|
package/lib/cjs/config/pdf.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const pdf = {
|
|
4
|
-
templates: {
|
|
5
|
-
pdf: {
|
|
6
|
-
static: {
|
|
7
|
-
port: 3000,
|
|
8
|
-
},
|
|
9
|
-
args: {
|
|
10
|
-
headless: true,
|
|
11
|
-
},
|
|
12
|
-
options: {},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
exports.default = pdf;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const pdf = {
|
|
4
|
+
templates: {
|
|
5
|
+
pdf: {
|
|
6
|
+
static: {
|
|
7
|
+
port: 3000,
|
|
8
|
+
},
|
|
9
|
+
args: {
|
|
10
|
+
headless: true,
|
|
11
|
+
},
|
|
12
|
+
options: {},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
exports.default = pdf;
|
|
17
17
|
//# sourceMappingURL=pdf.js.map
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { PDFOptions } from 'puppeteer';
|
|
3
|
-
import { TemplateRenderer, Templates } from '@spinajs/templates';
|
|
4
|
-
import { IInstanceCheck } from '@spinajs/di';
|
|
5
|
-
import { Log } from '@spinajs/log';
|
|
6
|
-
import * as http from 'http';
|
|
7
|
-
import '@spinajs/templates-pug';
|
|
8
|
-
export declare class PdfRenderer extends TemplateRenderer implements IInstanceCheck {
|
|
9
|
-
protected pdfOptions: PDFOptions;
|
|
10
|
-
/**
|
|
11
|
-
* General options from configuration
|
|
12
|
-
*/
|
|
13
|
-
protected Options: any;
|
|
14
|
-
protected Log: Log;
|
|
15
|
-
protected TemplatingService: Templates;
|
|
16
|
-
get Type(): string;
|
|
17
|
-
get Extension(): string;
|
|
18
|
-
constructor(pdfOptions: PDFOptions);
|
|
19
|
-
__checkInstance__(creationOptions: any): boolean;
|
|
20
|
-
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
21
|
-
render(_templateName: string, _model: unknown, _language?: string): Promise<string>;
|
|
22
|
-
protected compile(_path: string): Promise<void>;
|
|
23
|
-
protected runLocalServer(basePath: string): Promise<http.Server>;
|
|
24
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PDFOptions } from 'puppeteer';
|
|
3
|
+
import { TemplateRenderer, Templates } from '@spinajs/templates';
|
|
4
|
+
import { IInstanceCheck } from '@spinajs/di';
|
|
5
|
+
import { Log } from '@spinajs/log';
|
|
6
|
+
import * as http from 'http';
|
|
7
|
+
import '@spinajs/templates-pug';
|
|
8
|
+
export declare class PdfRenderer extends TemplateRenderer implements IInstanceCheck {
|
|
9
|
+
protected pdfOptions: PDFOptions;
|
|
10
|
+
/**
|
|
11
|
+
* General options from configuration
|
|
12
|
+
*/
|
|
13
|
+
protected Options: any;
|
|
14
|
+
protected Log: Log;
|
|
15
|
+
protected TemplatingService: Templates;
|
|
16
|
+
get Type(): string;
|
|
17
|
+
get Extension(): string;
|
|
18
|
+
constructor(pdfOptions: PDFOptions);
|
|
19
|
+
__checkInstance__(creationOptions: any): boolean;
|
|
20
|
+
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
21
|
+
render(_templateName: string, _model: unknown, _language?: string): Promise<string>;
|
|
22
|
+
protected compile(_path: string): Promise<void>;
|
|
23
|
+
protected runLocalServer(basePath: string): Promise<http.Server>;
|
|
24
|
+
}
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PdfRenderer = void 0;
|
|
16
|
-
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
17
|
-
const exceptions_1 = require("@spinajs/exceptions");
|
|
18
|
-
const templates_1 = require("@spinajs/templates");
|
|
19
|
-
const configuration_1 = require("@spinajs/configuration");
|
|
20
|
-
const di_1 = require("@spinajs/di");
|
|
21
|
-
const path_1 = require("path");
|
|
22
|
-
const log_1 = require("@spinajs/log");
|
|
23
|
-
const express_1 = __importDefault(require("express"));
|
|
24
|
-
const cors_1 = __importDefault(require("cors"));
|
|
25
|
-
require("@spinajs/templates-pug");
|
|
26
|
-
let PdfRenderer = class PdfRenderer extends templates_1.TemplateRenderer {
|
|
27
|
-
get Type() {
|
|
28
|
-
return 'pdf';
|
|
29
|
-
}
|
|
30
|
-
get Extension() {
|
|
31
|
-
return '.pdf';
|
|
32
|
-
}
|
|
33
|
-
constructor(pdfOptions) {
|
|
34
|
-
super();
|
|
35
|
-
this.pdfOptions = pdfOptions;
|
|
36
|
-
}
|
|
37
|
-
__checkInstance__(creationOptions) {
|
|
38
|
-
return JSON.stringify(this.pdfOptions) === JSON.stringify(creationOptions);
|
|
39
|
-
}
|
|
40
|
-
async renderToFile(template, model, filePath, language) {
|
|
41
|
-
let server = null;
|
|
42
|
-
let browser = null;
|
|
43
|
-
try {
|
|
44
|
-
this.Log.timeStart(`pdf-template-rendering-${filePath}`);
|
|
45
|
-
this.Log.trace(`Rendering pdf template ${template} to file ${filePath}`);
|
|
46
|
-
const templateBasePath = (0, path_1.dirname)(template);
|
|
47
|
-
const compiledTemplate = await this.TemplatingService.render((0, path_1.join)(templateBasePath, (0, path_1.basename)(template, '.pdf')) + '.pug', model, language);
|
|
48
|
-
// fire up local http server for serving images etc
|
|
49
|
-
// becouse chromium prevents from reading local files when not
|
|
50
|
-
// rendering file with file:// protocol for security reasons
|
|
51
|
-
server = await this.runLocalServer(templateBasePath);
|
|
52
|
-
browser = await puppeteer_1.default.launch(this.Options.args);
|
|
53
|
-
const page = await browser.newPage();
|
|
54
|
-
page
|
|
55
|
-
.on('console', (message) => this.Log.trace(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
56
|
-
.on('pageerror', ({ message }) => this.Log.error(message))
|
|
57
|
-
.on('response', (response) => this.Log.trace(`${response.status()} ${response.url()}`))
|
|
58
|
-
.on('requestfailed', (request) => this.Log.error(`${request.failure().errorText} ${request.url()}`));
|
|
59
|
-
await page.setBypassCSP(true);
|
|
60
|
-
await page.setContent(compiledTemplate);
|
|
61
|
-
await page.pdf({
|
|
62
|
-
path: filePath,
|
|
63
|
-
...this.pdfOptions,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
this.Log.error(err, `Error rendering pdf template ${template} to file ${filePath}`);
|
|
68
|
-
throw err;
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
const duration = this.Log.timeEnd(`pdf-template-rendering-${filePath}`);
|
|
72
|
-
this.Log.trace(`Ended rendering pdf template ${template} to file ${filePath}, took: ${duration}ms`);
|
|
73
|
-
if (duration > this.Options.renderDurationWarning) {
|
|
74
|
-
this.Log.warn(`Rendering pdf template ${template} to file ${filePath} took too long.`);
|
|
75
|
-
}
|
|
76
|
-
if (browser) {
|
|
77
|
-
await browser.close();
|
|
78
|
-
}
|
|
79
|
-
if (server) {
|
|
80
|
-
await server.close();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async render(_templateName, _model, _language) {
|
|
85
|
-
throw new exceptions_1.NotSupported('cannot render pdf template to string');
|
|
86
|
-
}
|
|
87
|
-
// no compilation at start
|
|
88
|
-
async compile(_path) { }
|
|
89
|
-
async runLocalServer(basePath) {
|
|
90
|
-
const self = this;
|
|
91
|
-
const app = (0, express_1.default)();
|
|
92
|
-
app.use((0, cors_1.default)());
|
|
93
|
-
app.use(express_1.default.static(basePath));
|
|
94
|
-
return new Promise((resolve, reject) => {
|
|
95
|
-
app
|
|
96
|
-
.listen(this.Options.static.port, function () {
|
|
97
|
-
self.Log.trace(`PDF image server started`);
|
|
98
|
-
self.Log.trace(`PDF static file dir at ${basePath}`);
|
|
99
|
-
resolve(this);
|
|
100
|
-
})
|
|
101
|
-
.on('error', (err) => {
|
|
102
|
-
self.Log.error(err, `PDF image server cannot start`);
|
|
103
|
-
reject(err);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
PdfRenderer
|
|
121
|
-
|
|
122
|
-
(0, di_1.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PdfRenderer = void 0;
|
|
16
|
+
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
17
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
18
|
+
const templates_1 = require("@spinajs/templates");
|
|
19
|
+
const configuration_1 = require("@spinajs/configuration");
|
|
20
|
+
const di_1 = require("@spinajs/di");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
const log_1 = require("@spinajs/log");
|
|
23
|
+
const express_1 = __importDefault(require("express"));
|
|
24
|
+
const cors_1 = __importDefault(require("cors"));
|
|
25
|
+
require("@spinajs/templates-pug");
|
|
26
|
+
let PdfRenderer = class PdfRenderer extends templates_1.TemplateRenderer {
|
|
27
|
+
get Type() {
|
|
28
|
+
return 'pdf';
|
|
29
|
+
}
|
|
30
|
+
get Extension() {
|
|
31
|
+
return '.pdf';
|
|
32
|
+
}
|
|
33
|
+
constructor(pdfOptions) {
|
|
34
|
+
super();
|
|
35
|
+
this.pdfOptions = pdfOptions;
|
|
36
|
+
}
|
|
37
|
+
__checkInstance__(creationOptions) {
|
|
38
|
+
return JSON.stringify(this.pdfOptions) === JSON.stringify(creationOptions);
|
|
39
|
+
}
|
|
40
|
+
async renderToFile(template, model, filePath, language) {
|
|
41
|
+
let server = null;
|
|
42
|
+
let browser = null;
|
|
43
|
+
try {
|
|
44
|
+
this.Log.timeStart(`pdf-template-rendering-${filePath}`);
|
|
45
|
+
this.Log.trace(`Rendering pdf template ${template} to file ${filePath}`);
|
|
46
|
+
const templateBasePath = (0, path_1.dirname)(template);
|
|
47
|
+
const compiledTemplate = await this.TemplatingService.render((0, path_1.join)(templateBasePath, (0, path_1.basename)(template, '.pdf')) + '.pug', model, language);
|
|
48
|
+
// fire up local http server for serving images etc
|
|
49
|
+
// becouse chromium prevents from reading local files when not
|
|
50
|
+
// rendering file with file:// protocol for security reasons
|
|
51
|
+
server = await this.runLocalServer(templateBasePath);
|
|
52
|
+
browser = await puppeteer_1.default.launch(this.Options.args);
|
|
53
|
+
const page = await browser.newPage();
|
|
54
|
+
page
|
|
55
|
+
.on('console', (message) => this.Log.trace(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
56
|
+
.on('pageerror', ({ message }) => this.Log.error(message))
|
|
57
|
+
.on('response', (response) => this.Log.trace(`${response.status()} ${response.url()}`))
|
|
58
|
+
.on('requestfailed', (request) => this.Log.error(`${request.failure().errorText} ${request.url()}`));
|
|
59
|
+
await page.setBypassCSP(true);
|
|
60
|
+
await page.setContent(compiledTemplate);
|
|
61
|
+
await page.pdf({
|
|
62
|
+
path: filePath,
|
|
63
|
+
...this.pdfOptions,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
this.Log.error(err, `Error rendering pdf template ${template} to file ${filePath}`);
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
const duration = this.Log.timeEnd(`pdf-template-rendering-${filePath}`);
|
|
72
|
+
this.Log.trace(`Ended rendering pdf template ${template} to file ${filePath}, took: ${duration}ms`);
|
|
73
|
+
if (duration > this.Options.renderDurationWarning) {
|
|
74
|
+
this.Log.warn(`Rendering pdf template ${template} to file ${filePath} took too long.`);
|
|
75
|
+
}
|
|
76
|
+
if (browser) {
|
|
77
|
+
await browser.close();
|
|
78
|
+
}
|
|
79
|
+
if (server) {
|
|
80
|
+
await server.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async render(_templateName, _model, _language) {
|
|
85
|
+
throw new exceptions_1.NotSupported('cannot render pdf template to string');
|
|
86
|
+
}
|
|
87
|
+
// no compilation at start
|
|
88
|
+
async compile(_path) { }
|
|
89
|
+
async runLocalServer(basePath) {
|
|
90
|
+
const self = this;
|
|
91
|
+
const app = (0, express_1.default)();
|
|
92
|
+
app.use((0, cors_1.default)());
|
|
93
|
+
app.use(express_1.default.static(basePath));
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
app
|
|
96
|
+
.listen(this.Options.static.port, function () {
|
|
97
|
+
self.Log.trace(`PDF image server started`);
|
|
98
|
+
self.Log.trace(`PDF static file dir at ${basePath}`);
|
|
99
|
+
resolve(this);
|
|
100
|
+
})
|
|
101
|
+
.on('error', (err) => {
|
|
102
|
+
self.Log.error(err, `PDF image server cannot start`);
|
|
103
|
+
reject(err);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.PdfRenderer = PdfRenderer;
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, configuration_1.Config)('templates.pdf'),
|
|
111
|
+
__metadata("design:type", Object)
|
|
112
|
+
], PdfRenderer.prototype, "Options", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, log_1.Logger)('pdf-templates'),
|
|
115
|
+
__metadata("design:type", log_1.Log)
|
|
116
|
+
], PdfRenderer.prototype, "Log", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, di_1.LazyInject)(),
|
|
119
|
+
__metadata("design:type", templates_1.Templates)
|
|
120
|
+
], PdfRenderer.prototype, "TemplatingService", void 0);
|
|
121
|
+
exports.PdfRenderer = PdfRenderer = __decorate([
|
|
122
|
+
(0, di_1.Injectable)(templates_1.TemplateRenderer),
|
|
123
|
+
(0, di_1.PerInstanceCheck)(),
|
|
124
|
+
__metadata("design:paramtypes", [Object])
|
|
125
|
+
], PdfRenderer);
|
|
126
126
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @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AE;;GACN,WAAW,CA2GvB"}
|
package/lib/mjs/config/pdf.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
declare const pdf: {
|
|
2
|
-
templates: {
|
|
3
|
-
pdf: {
|
|
4
|
-
static: {
|
|
5
|
-
port: number;
|
|
6
|
-
};
|
|
7
|
-
args: {
|
|
8
|
-
headless: boolean;
|
|
9
|
-
};
|
|
10
|
-
options: {};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export default pdf;
|
|
1
|
+
declare const pdf: {
|
|
2
|
+
templates: {
|
|
3
|
+
pdf: {
|
|
4
|
+
static: {
|
|
5
|
+
port: number;
|
|
6
|
+
};
|
|
7
|
+
args: {
|
|
8
|
+
headless: boolean;
|
|
9
|
+
};
|
|
10
|
+
options: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default pdf;
|
|
15
15
|
//# sourceMappingURL=pdf.d.ts.map
|
package/lib/mjs/config/pdf.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const pdf = {
|
|
2
|
-
templates: {
|
|
3
|
-
pdf: {
|
|
4
|
-
static: {
|
|
5
|
-
port: 3000,
|
|
6
|
-
},
|
|
7
|
-
args: {
|
|
8
|
-
headless: true,
|
|
9
|
-
},
|
|
10
|
-
options: {},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export default pdf;
|
|
1
|
+
const pdf = {
|
|
2
|
+
templates: {
|
|
3
|
+
pdf: {
|
|
4
|
+
static: {
|
|
5
|
+
port: 3000,
|
|
6
|
+
},
|
|
7
|
+
args: {
|
|
8
|
+
headless: true,
|
|
9
|
+
},
|
|
10
|
+
options: {},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default pdf;
|
|
15
15
|
//# sourceMappingURL=pdf.js.map
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { PDFOptions } from 'puppeteer';
|
|
3
|
-
import { TemplateRenderer, Templates } from '@spinajs/templates';
|
|
4
|
-
import { IInstanceCheck } from '@spinajs/di';
|
|
5
|
-
import { Log } from '@spinajs/log';
|
|
6
|
-
import * as http from 'http';
|
|
7
|
-
import '@spinajs/templates-pug';
|
|
8
|
-
export declare class PdfRenderer extends TemplateRenderer implements IInstanceCheck {
|
|
9
|
-
protected pdfOptions: PDFOptions;
|
|
10
|
-
/**
|
|
11
|
-
* General options from configuration
|
|
12
|
-
*/
|
|
13
|
-
protected Options: any;
|
|
14
|
-
protected Log: Log;
|
|
15
|
-
protected TemplatingService: Templates;
|
|
16
|
-
get Type(): string;
|
|
17
|
-
get Extension(): string;
|
|
18
|
-
constructor(pdfOptions: PDFOptions);
|
|
19
|
-
__checkInstance__(creationOptions: any): boolean;
|
|
20
|
-
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
21
|
-
render(_templateName: string, _model: unknown, _language?: string): Promise<string>;
|
|
22
|
-
protected compile(_path: string): Promise<void>;
|
|
23
|
-
protected runLocalServer(basePath: string): Promise<http.Server>;
|
|
24
|
-
}
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { PDFOptions } from 'puppeteer';
|
|
3
|
+
import { TemplateRenderer, Templates } from '@spinajs/templates';
|
|
4
|
+
import { IInstanceCheck } from '@spinajs/di';
|
|
5
|
+
import { Log } from '@spinajs/log';
|
|
6
|
+
import * as http from 'http';
|
|
7
|
+
import '@spinajs/templates-pug';
|
|
8
|
+
export declare class PdfRenderer extends TemplateRenderer implements IInstanceCheck {
|
|
9
|
+
protected pdfOptions: PDFOptions;
|
|
10
|
+
/**
|
|
11
|
+
* General options from configuration
|
|
12
|
+
*/
|
|
13
|
+
protected Options: any;
|
|
14
|
+
protected Log: Log;
|
|
15
|
+
protected TemplatingService: Templates;
|
|
16
|
+
get Type(): string;
|
|
17
|
+
get Extension(): string;
|
|
18
|
+
constructor(pdfOptions: PDFOptions);
|
|
19
|
+
__checkInstance__(creationOptions: any): boolean;
|
|
20
|
+
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
21
|
+
render(_templateName: string, _model: unknown, _language?: string): Promise<string>;
|
|
22
|
+
protected compile(_path: string): Promise<void>;
|
|
23
|
+
protected runLocalServer(basePath: string): Promise<http.Server>;
|
|
24
|
+
}
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|