@shad0wz7/nestjs-pdf 1.1.1 → 2.0.1
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/README.md +7 -3
- package/dist/index.d.mts +102 -14
- package/dist/index.d.ts +102 -14
- package/dist/index.js +352 -138
- package/dist/index.mjs +340 -128
- package/package.json +16 -3
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# nestjs-pdf
|
|
2
2
|
|
|
3
|
-
A small NestJS library to generate and manipulate PDFs using Puppeteer and Handlebars.
|
|
3
|
+
A small NestJS library to generate and manipulate PDFs using Puppeteer and multiple template engines, including Handlebars, EJS, Pug, and MJML.
|
|
4
4
|
|
|
5
5
|
Main features:
|
|
6
|
-
- Generate PDFs from HTML or
|
|
6
|
+
- Generate PDFs from HTML, Handlebars, EJS, Pug or MJML templates
|
|
7
7
|
- Concurrency limiting for Puppeteer jobs (p-limit)
|
|
8
8
|
- Add signature fields based on a text anchor in an existing PDF
|
|
9
9
|
- Simple API (module and service) to integrate easily into a Nest application
|
|
@@ -68,7 +68,11 @@ Use a Handlebars template (string or file):
|
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
70
|
const template = '<h1>{{title}}</h1><p>{{content}}</p>';
|
|
71
|
-
const pdf = await pdfService.
|
|
71
|
+
const pdf = await pdfService.generatePdfFromTemplateHbsString(template, { title: 'T', content: '...' });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const pdf = await pdfService.generatePdfFromTemplateHbsFile(filePath, { title: 'T', content: '...' });
|
|
72
76
|
```
|
|
73
77
|
|
|
74
78
|
Add a signature field to an existing PDF (anchor-based):
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,9 @@ import { HandlebarsOptions } from '@gboutte/nestjs-hbs/dist/handlebars-options.i
|
|
|
3
3
|
import * as puppeteerBrowser from '@puppeteer/browsers';
|
|
4
4
|
import { Browser as Browser$1 } from '@puppeteer/browsers';
|
|
5
5
|
import { Browser, BrowserContext, PDFOptions } from 'puppeteer';
|
|
6
|
+
import { MJMLParsingOptions } from 'mjml-core';
|
|
7
|
+
import pug, { LocalsObject } from 'pug';
|
|
8
|
+
import { Options, Data } from 'ejs';
|
|
6
9
|
import { HandlebarsService } from '@gboutte/nestjs-hbs';
|
|
7
10
|
|
|
8
11
|
declare enum BrowserTag {
|
|
@@ -50,9 +53,26 @@ declare class BrowserService implements OnModuleDestroy {
|
|
|
50
53
|
getLockedBuildId(browser: Browser$1): string | null;
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
type PugOptions = pug.Options;
|
|
57
|
+
declare class PugService {
|
|
58
|
+
render(template: string, data?: pug.LocalsObject, options?: PugOptions): string;
|
|
59
|
+
renderFile(filePath: string, data?: pug.LocalsObject, options?: PugOptions): string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface EjsOptions extends Omit<Options, 'async'> {
|
|
63
|
+
async?: boolean;
|
|
64
|
+
}
|
|
65
|
+
declare class EjsService {
|
|
66
|
+
render(template: string, data?: Data, options?: EjsOptions): Promise<string>;
|
|
67
|
+
renderFile(filePath: string, data?: Data, options?: EjsOptions): Promise<string>;
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
interface PuppeteerParameters {
|
|
54
71
|
pdfOptions?: PDFOptions;
|
|
55
72
|
hbsOptions?: HandlebarsOptions;
|
|
73
|
+
mjmlOptions?: MJMLParsingOptions;
|
|
74
|
+
pugOptions?: PugOptions;
|
|
75
|
+
ejsOptions?: EjsOptions;
|
|
56
76
|
chromiumRevision?: string;
|
|
57
77
|
buildId?: string;
|
|
58
78
|
headless?: boolean | 'shell';
|
|
@@ -73,15 +93,29 @@ declare class NestjsPdfModule {
|
|
|
73
93
|
static forRootAsync(options: PdfLibModuleAsyncOptions): DynamicModule;
|
|
74
94
|
}
|
|
75
95
|
|
|
96
|
+
declare class MjmlService {
|
|
97
|
+
render(template: string, options?: MJMLParsingOptions): Promise<string>;
|
|
98
|
+
renderFile(filePath: string, options?: MJMLParsingOptions): Promise<string>;
|
|
99
|
+
}
|
|
100
|
+
|
|
76
101
|
declare class PuppeteerService {
|
|
77
102
|
private readonly hbsService;
|
|
78
103
|
private readonly browserService;
|
|
79
104
|
private readonly options;
|
|
80
|
-
|
|
105
|
+
private readonly mjmlService?;
|
|
106
|
+
private readonly pugService?;
|
|
107
|
+
private readonly ejsService?;
|
|
108
|
+
constructor(hbsService: HandlebarsService, browserService: BrowserService, options: PuppeteerParameters, mjmlService?: MjmlService | undefined, pugService?: PugService | undefined, ejsService?: EjsService | undefined);
|
|
81
109
|
private readonly limit;
|
|
82
110
|
generatePdfFromHtml(html: string, options?: PuppeteerParameters): Promise<Uint8Array>;
|
|
83
|
-
|
|
84
|
-
|
|
111
|
+
generatePdfFromTemplateHbsString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
112
|
+
generatePdfFromTemplateHbsFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
113
|
+
generatePdfFromMjmlString(template: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
114
|
+
generatePdfFromMjmlFile(file: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
115
|
+
generatePdfFromPugString(template: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
116
|
+
generatePdfFromPugFile(file: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
117
|
+
generatePdfFromEjsString(template: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
118
|
+
generatePdfFromEjsFile(file: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
85
119
|
}
|
|
86
120
|
|
|
87
121
|
declare class NestjsPdfService {
|
|
@@ -95,6 +129,7 @@ declare class NestjsPdfService {
|
|
|
95
129
|
*/
|
|
96
130
|
generatePdfFromHtml(html: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
97
131
|
/**
|
|
132
|
+
* @deprecated Use the new method generatePdfFromTemplateHbsString
|
|
98
133
|
* @param template Handlebars template string
|
|
99
134
|
* @param parameters Data parameters to inject into the template
|
|
100
135
|
* @param options PDF generation options (optional)
|
|
@@ -103,6 +138,7 @@ declare class NestjsPdfService {
|
|
|
103
138
|
*/
|
|
104
139
|
generatePdfFromTemplateString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
105
140
|
/**
|
|
141
|
+
* @deprecated Use the new method generatePdfFromTemplateHbsFile
|
|
106
142
|
* @param file Path to the Handlebars template file
|
|
107
143
|
* @param parameters Data parameters to inject into the template
|
|
108
144
|
* @param options PDF generation options (optional)
|
|
@@ -110,6 +146,68 @@ declare class NestjsPdfService {
|
|
|
110
146
|
* @description This method generates a PDF from a Handlebars template located at the specified file path. The file path is passed as a string in the `file` parameter. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
|
|
111
147
|
*/
|
|
112
148
|
generatePdfFromTemplateFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
149
|
+
/**
|
|
150
|
+
* @param template Handlebars template string
|
|
151
|
+
* @param parameters Data parameters to inject into the template
|
|
152
|
+
* @param options PDF generation options (optional)
|
|
153
|
+
* @returns PDF generated from the provided Handlebars template with parameters applied
|
|
154
|
+
* @description This method generates a PDF from a Handlebars template provided as a string. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
|
|
155
|
+
*/
|
|
156
|
+
generatePdfFromTemplateHbsString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
157
|
+
/**
|
|
158
|
+
* @param file Path to the Handlebars template file
|
|
159
|
+
* @param parameters Data parameters to inject into the template
|
|
160
|
+
* @param options PDF generation options (optional)
|
|
161
|
+
* @returns PDF generated from the Handlebars template at the provided file path with parameters applied
|
|
162
|
+
* @description This method generates a PDF from a Handlebars template located at the specified file path. The file path is passed as a string in the `file` parameter. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
|
|
163
|
+
*/
|
|
164
|
+
generatePdfFromTemplateHbsFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
165
|
+
/**
|
|
166
|
+
* @param template MJML template string
|
|
167
|
+
* @param options PDF generation options (optional)
|
|
168
|
+
* @returns PDF generated from the provided MJML template
|
|
169
|
+
* @description This method generates a PDF from an MJML template provided as a string. MJML (MJML Markup Language) is a markup language designed to reduce the pain of coding a responsive email. The template is first rendered to HTML using the MJML renderer, then converted to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the second argument.
|
|
170
|
+
*/
|
|
171
|
+
generatePdfFromMjmlString(template: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
172
|
+
/**
|
|
173
|
+
* @param file Path to the MJML template file
|
|
174
|
+
* @param options PDF generation options (optional)
|
|
175
|
+
* @returns PDF generated from the MJML template at the provided file path
|
|
176
|
+
* @description This method generates a PDF from an MJML template located at the specified file path. The file path is passed as a string in the `file` parameter. The template is first rendered to HTML using the MJML renderer, then converted to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the second argument.
|
|
177
|
+
*/
|
|
178
|
+
generatePdfFromMjmlFile(file: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
179
|
+
/**
|
|
180
|
+
* @param template EJS template string
|
|
181
|
+
* @param data Data to inject into the template
|
|
182
|
+
* @param options PDF generation options (optional)
|
|
183
|
+
* @returns PDF generated from the provided EJS template with data applied
|
|
184
|
+
* @description This method generates a PDF from an EJS (Embedded JavaScript) template provided as a string. EJS is a templating language with a simple, straightforward syntax. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
185
|
+
*/
|
|
186
|
+
generatePdfFromEjsString(template: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
187
|
+
/**
|
|
188
|
+
* @param file Path to the EJS template file
|
|
189
|
+
* @param data Data to inject into the template
|
|
190
|
+
* @param options PDF generation options (optional)
|
|
191
|
+
* @returns PDF generated from the EJS template at the provided file path with data applied
|
|
192
|
+
* @description This method generates a PDF from an EJS template located at the specified file path. The file path is passed as a string in the `file` parameter. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
193
|
+
*/
|
|
194
|
+
generatePdfFromEjsFile(file: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
195
|
+
/**
|
|
196
|
+
* @param template Pug template string
|
|
197
|
+
* @param data Data to inject into the template
|
|
198
|
+
* @param options PDF generation options (optional)
|
|
199
|
+
* @returns PDF generated from the provided Pug template with data applied
|
|
200
|
+
* @description This method generates a PDF from a Pug template provided as a string. Pug is a clean, whitespace-sensitive syntax for writing HTML. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
201
|
+
*/
|
|
202
|
+
generatePdfFromPugString(template: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
203
|
+
/**
|
|
204
|
+
* @param file Path to the Pug template file
|
|
205
|
+
* @param data Data to inject into the template
|
|
206
|
+
* @param options PDF generation options (optional)
|
|
207
|
+
* @returns PDF generated from the Pug template at the provided file path with data applied
|
|
208
|
+
* @description This method generates a PDF from a Pug template located at the specified file path. The file path is passed as a string in the `file` parameter. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
209
|
+
*/
|
|
210
|
+
generatePdfFromPugFile(file: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
113
211
|
/**
|
|
114
212
|
* @param pdf The PDF bytes to modify
|
|
115
213
|
* @param fieldName The name of the signature field to add (default: 'SignatureDebtor')
|
|
@@ -148,16 +246,6 @@ declare class PuppeteerModule implements OnModuleInit {
|
|
|
148
246
|
static forRootAsync(options: PuppeteerModuleAsyncOptions): DynamicModule;
|
|
149
247
|
}
|
|
150
248
|
|
|
151
|
-
interface PuppeteerHandlebarsModuleAsyncOptions {
|
|
152
|
-
imports?: DynamicModule[];
|
|
153
|
-
inject?: (InjectionToken | OptionalFactoryDependency)[];
|
|
154
|
-
useFactory: (...args: unknown[]) => Promise<HandlebarsOptions> | HandlebarsOptions;
|
|
155
|
-
}
|
|
156
|
-
declare class PuppeteerHandlebarsModule {
|
|
157
|
-
static forRoot(handlebarsOptions: HandlebarsOptions): DynamicModule;
|
|
158
|
-
static forRootAsync(options: PuppeteerHandlebarsModuleAsyncOptions): DynamicModule;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
249
|
/**
|
|
162
250
|
* Get the relative path to a value from the module directory.
|
|
163
251
|
* @param moduleDir the path of the module, typically __dirname
|
|
@@ -169,4 +257,4 @@ declare class PuppeteerHandlebarsModule {
|
|
|
169
257
|
*/
|
|
170
258
|
declare function getRelativePathToValue(moduleDir: string, relativeToModule: string): string;
|
|
171
259
|
|
|
172
|
-
export { NestjsPdfModule, NestjsPdfService, type PdfLibModuleAsyncOptions,
|
|
260
|
+
export { type EjsOptions, EjsService, MjmlService, NestjsPdfModule, NestjsPdfService, type PdfLibModuleAsyncOptions, type PugOptions, PugService, PuppeteerModule, type PuppeteerModuleAsyncOptions, type PuppeteerParameters, PuppeteerService, getRelativePathToValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { HandlebarsOptions } from '@gboutte/nestjs-hbs/dist/handlebars-options.i
|
|
|
3
3
|
import * as puppeteerBrowser from '@puppeteer/browsers';
|
|
4
4
|
import { Browser as Browser$1 } from '@puppeteer/browsers';
|
|
5
5
|
import { Browser, BrowserContext, PDFOptions } from 'puppeteer';
|
|
6
|
+
import { MJMLParsingOptions } from 'mjml-core';
|
|
7
|
+
import pug, { LocalsObject } from 'pug';
|
|
8
|
+
import { Options, Data } from 'ejs';
|
|
6
9
|
import { HandlebarsService } from '@gboutte/nestjs-hbs';
|
|
7
10
|
|
|
8
11
|
declare enum BrowserTag {
|
|
@@ -50,9 +53,26 @@ declare class BrowserService implements OnModuleDestroy {
|
|
|
50
53
|
getLockedBuildId(browser: Browser$1): string | null;
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
type PugOptions = pug.Options;
|
|
57
|
+
declare class PugService {
|
|
58
|
+
render(template: string, data?: pug.LocalsObject, options?: PugOptions): string;
|
|
59
|
+
renderFile(filePath: string, data?: pug.LocalsObject, options?: PugOptions): string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface EjsOptions extends Omit<Options, 'async'> {
|
|
63
|
+
async?: boolean;
|
|
64
|
+
}
|
|
65
|
+
declare class EjsService {
|
|
66
|
+
render(template: string, data?: Data, options?: EjsOptions): Promise<string>;
|
|
67
|
+
renderFile(filePath: string, data?: Data, options?: EjsOptions): Promise<string>;
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
interface PuppeteerParameters {
|
|
54
71
|
pdfOptions?: PDFOptions;
|
|
55
72
|
hbsOptions?: HandlebarsOptions;
|
|
73
|
+
mjmlOptions?: MJMLParsingOptions;
|
|
74
|
+
pugOptions?: PugOptions;
|
|
75
|
+
ejsOptions?: EjsOptions;
|
|
56
76
|
chromiumRevision?: string;
|
|
57
77
|
buildId?: string;
|
|
58
78
|
headless?: boolean | 'shell';
|
|
@@ -73,15 +93,29 @@ declare class NestjsPdfModule {
|
|
|
73
93
|
static forRootAsync(options: PdfLibModuleAsyncOptions): DynamicModule;
|
|
74
94
|
}
|
|
75
95
|
|
|
96
|
+
declare class MjmlService {
|
|
97
|
+
render(template: string, options?: MJMLParsingOptions): Promise<string>;
|
|
98
|
+
renderFile(filePath: string, options?: MJMLParsingOptions): Promise<string>;
|
|
99
|
+
}
|
|
100
|
+
|
|
76
101
|
declare class PuppeteerService {
|
|
77
102
|
private readonly hbsService;
|
|
78
103
|
private readonly browserService;
|
|
79
104
|
private readonly options;
|
|
80
|
-
|
|
105
|
+
private readonly mjmlService?;
|
|
106
|
+
private readonly pugService?;
|
|
107
|
+
private readonly ejsService?;
|
|
108
|
+
constructor(hbsService: HandlebarsService, browserService: BrowserService, options: PuppeteerParameters, mjmlService?: MjmlService | undefined, pugService?: PugService | undefined, ejsService?: EjsService | undefined);
|
|
81
109
|
private readonly limit;
|
|
82
110
|
generatePdfFromHtml(html: string, options?: PuppeteerParameters): Promise<Uint8Array>;
|
|
83
|
-
|
|
84
|
-
|
|
111
|
+
generatePdfFromTemplateHbsString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
112
|
+
generatePdfFromTemplateHbsFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
113
|
+
generatePdfFromMjmlString(template: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
114
|
+
generatePdfFromMjmlFile(file: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
115
|
+
generatePdfFromPugString(template: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
116
|
+
generatePdfFromPugFile(file: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
117
|
+
generatePdfFromEjsString(template: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
118
|
+
generatePdfFromEjsFile(file: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
85
119
|
}
|
|
86
120
|
|
|
87
121
|
declare class NestjsPdfService {
|
|
@@ -95,6 +129,7 @@ declare class NestjsPdfService {
|
|
|
95
129
|
*/
|
|
96
130
|
generatePdfFromHtml(html: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
97
131
|
/**
|
|
132
|
+
* @deprecated Use the new method generatePdfFromTemplateHbsString
|
|
98
133
|
* @param template Handlebars template string
|
|
99
134
|
* @param parameters Data parameters to inject into the template
|
|
100
135
|
* @param options PDF generation options (optional)
|
|
@@ -103,6 +138,7 @@ declare class NestjsPdfService {
|
|
|
103
138
|
*/
|
|
104
139
|
generatePdfFromTemplateString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
105
140
|
/**
|
|
141
|
+
* @deprecated Use the new method generatePdfFromTemplateHbsFile
|
|
106
142
|
* @param file Path to the Handlebars template file
|
|
107
143
|
* @param parameters Data parameters to inject into the template
|
|
108
144
|
* @param options PDF generation options (optional)
|
|
@@ -110,6 +146,68 @@ declare class NestjsPdfService {
|
|
|
110
146
|
* @description This method generates a PDF from a Handlebars template located at the specified file path. The file path is passed as a string in the `file` parameter. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
|
|
111
147
|
*/
|
|
112
148
|
generatePdfFromTemplateFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
149
|
+
/**
|
|
150
|
+
* @param template Handlebars template string
|
|
151
|
+
* @param parameters Data parameters to inject into the template
|
|
152
|
+
* @param options PDF generation options (optional)
|
|
153
|
+
* @returns PDF generated from the provided Handlebars template with parameters applied
|
|
154
|
+
* @description This method generates a PDF from a Handlebars template provided as a string. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
|
|
155
|
+
*/
|
|
156
|
+
generatePdfFromTemplateHbsString(template: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
157
|
+
/**
|
|
158
|
+
* @param file Path to the Handlebars template file
|
|
159
|
+
* @param parameters Data parameters to inject into the template
|
|
160
|
+
* @param options PDF generation options (optional)
|
|
161
|
+
* @returns PDF generated from the Handlebars template at the provided file path with parameters applied
|
|
162
|
+
* @description This method generates a PDF from a Handlebars template located at the specified file path. The file path is passed as a string in the `file` parameter. The parameters to inject into the template are passed in the `parameters` object, which is used to render the template before converting it to PDF. PDF generation options can also be customized by passing a `PuppeteerParameters` object as the third argument. This allows you to control various aspects of PDF rendering, such as page size, margins, background display, etc. If no options are provided, the default parameters defined in the Puppeteer service will be used.
|
|
163
|
+
*/
|
|
164
|
+
generatePdfFromTemplateHbsFile(file: string, parameters?: any, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
165
|
+
/**
|
|
166
|
+
* @param template MJML template string
|
|
167
|
+
* @param options PDF generation options (optional)
|
|
168
|
+
* @returns PDF generated from the provided MJML template
|
|
169
|
+
* @description This method generates a PDF from an MJML template provided as a string. MJML (MJML Markup Language) is a markup language designed to reduce the pain of coding a responsive email. The template is first rendered to HTML using the MJML renderer, then converted to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the second argument.
|
|
170
|
+
*/
|
|
171
|
+
generatePdfFromMjmlString(template: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
172
|
+
/**
|
|
173
|
+
* @param file Path to the MJML template file
|
|
174
|
+
* @param options PDF generation options (optional)
|
|
175
|
+
* @returns PDF generated from the MJML template at the provided file path
|
|
176
|
+
* @description This method generates a PDF from an MJML template located at the specified file path. The file path is passed as a string in the `file` parameter. The template is first rendered to HTML using the MJML renderer, then converted to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the second argument.
|
|
177
|
+
*/
|
|
178
|
+
generatePdfFromMjmlFile(file: string, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
179
|
+
/**
|
|
180
|
+
* @param template EJS template string
|
|
181
|
+
* @param data Data to inject into the template
|
|
182
|
+
* @param options PDF generation options (optional)
|
|
183
|
+
* @returns PDF generated from the provided EJS template with data applied
|
|
184
|
+
* @description This method generates a PDF from an EJS (Embedded JavaScript) template provided as a string. EJS is a templating language with a simple, straightforward syntax. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
185
|
+
*/
|
|
186
|
+
generatePdfFromEjsString(template: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
187
|
+
/**
|
|
188
|
+
* @param file Path to the EJS template file
|
|
189
|
+
* @param data Data to inject into the template
|
|
190
|
+
* @param options PDF generation options (optional)
|
|
191
|
+
* @returns PDF generated from the EJS template at the provided file path with data applied
|
|
192
|
+
* @description This method generates a PDF from an EJS template located at the specified file path. The file path is passed as a string in the `file` parameter. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
193
|
+
*/
|
|
194
|
+
generatePdfFromEjsFile(file: string, data?: Data, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
195
|
+
/**
|
|
196
|
+
* @param template Pug template string
|
|
197
|
+
* @param data Data to inject into the template
|
|
198
|
+
* @param options PDF generation options (optional)
|
|
199
|
+
* @returns PDF generated from the provided Pug template with data applied
|
|
200
|
+
* @description This method generates a PDF from a Pug template provided as a string. Pug is a clean, whitespace-sensitive syntax for writing HTML. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
201
|
+
*/
|
|
202
|
+
generatePdfFromPugString(template: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
203
|
+
/**
|
|
204
|
+
* @param file Path to the Pug template file
|
|
205
|
+
* @param data Data to inject into the template
|
|
206
|
+
* @param options PDF generation options (optional)
|
|
207
|
+
* @returns PDF generated from the Pug template at the provided file path with data applied
|
|
208
|
+
* @description This method generates a PDF from a Pug template located at the specified file path. The file path is passed as a string in the `file` parameter. The data to inject into the template is passed in the `data` object, which is used to render the template before converting it to PDF. PDF generation options can be customized by passing a `PuppeteerParameters` object as the third argument.
|
|
209
|
+
*/
|
|
210
|
+
generatePdfFromPugFile(file: string, data?: LocalsObject, options?: PuppeteerParameters): Promise<Uint8Array<ArrayBufferLike>>;
|
|
113
211
|
/**
|
|
114
212
|
* @param pdf The PDF bytes to modify
|
|
115
213
|
* @param fieldName The name of the signature field to add (default: 'SignatureDebtor')
|
|
@@ -148,16 +246,6 @@ declare class PuppeteerModule implements OnModuleInit {
|
|
|
148
246
|
static forRootAsync(options: PuppeteerModuleAsyncOptions): DynamicModule;
|
|
149
247
|
}
|
|
150
248
|
|
|
151
|
-
interface PuppeteerHandlebarsModuleAsyncOptions {
|
|
152
|
-
imports?: DynamicModule[];
|
|
153
|
-
inject?: (InjectionToken | OptionalFactoryDependency)[];
|
|
154
|
-
useFactory: (...args: unknown[]) => Promise<HandlebarsOptions> | HandlebarsOptions;
|
|
155
|
-
}
|
|
156
|
-
declare class PuppeteerHandlebarsModule {
|
|
157
|
-
static forRoot(handlebarsOptions: HandlebarsOptions): DynamicModule;
|
|
158
|
-
static forRootAsync(options: PuppeteerHandlebarsModuleAsyncOptions): DynamicModule;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
249
|
/**
|
|
162
250
|
* Get the relative path to a value from the module directory.
|
|
163
251
|
* @param moduleDir the path of the module, typically __dirname
|
|
@@ -169,4 +257,4 @@ declare class PuppeteerHandlebarsModule {
|
|
|
169
257
|
*/
|
|
170
258
|
declare function getRelativePathToValue(moduleDir: string, relativeToModule: string): string;
|
|
171
259
|
|
|
172
|
-
export { NestjsPdfModule, NestjsPdfService, type PdfLibModuleAsyncOptions,
|
|
260
|
+
export { type EjsOptions, EjsService, MjmlService, NestjsPdfModule, NestjsPdfService, type PdfLibModuleAsyncOptions, type PugOptions, PugService, PuppeteerModule, type PuppeteerModuleAsyncOptions, type PuppeteerParameters, PuppeteerService, getRelativePathToValue };
|