@shad0wz7/nestjs-pdf 2.2.1 → 2.3.0
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 +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +6 -5
- package/dist/index.mjs +6 -5
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# nestjs-pdf
|
|
2
2
|
|
|
3
|
-
A small NestJS library to generate and manipulate PDFs using Puppeteer and multiple template engines, including Handlebars, EJS, Pug, and
|
|
3
|
+
A small NestJS library to generate and manipulate PDFs using Puppeteer and multiple template engines, including Handlebars, EJS, Pug, MJML, Nunjucks, Eta and Mustache.
|
|
4
4
|
|
|
5
5
|
Main features:
|
|
6
6
|
|
|
7
|
-
- Generate PDFs from HTML, Handlebars, EJS, Pug or
|
|
7
|
+
- Generate PDFs from HTML, Handlebars, EJS, Pug, MJML, Nunjucks, Eta or Mustache templates
|
|
8
8
|
- Concurrency limiting for Puppeteer jobs (p-limit)
|
|
9
9
|
- Add signature fields based on a text anchor in an existing PDF
|
|
10
10
|
- Simple API (module and service) to integrate easily into a Nest application
|
|
@@ -128,6 +128,7 @@ The library exposes Puppeteer options via the `PuppeteerParameters` interface (s
|
|
|
128
128
|
| `buildId` | You can force the build id. Should be `string` |
|
|
129
129
|
| `cleanupBrowserCacheOnExit` | Define if you want to clean up the browser cache folder on exit. By default it's `true`. Allowed values: `true`,`false` |
|
|
130
130
|
| `extraPuppeteerArgs` | It passes some extra arguments to Puppeteer's launch method. You can check the default args at bellow. Should be `string[]` |
|
|
131
|
+
| `executablePath` | The path to the browser executable to use. If not specified, Puppeteer will install Chromium in cache dir. (useLockedBrowser is useless with this param specified) |
|
|
131
132
|
|
|
132
133
|
these are the default extra arguments passed to Puppeteer:
|
|
133
134
|
```ts
|
package/dist/index.d.mts
CHANGED
|
@@ -32,8 +32,8 @@ declare class BrowserService implements OnModuleDestroy {
|
|
|
32
32
|
private buildId;
|
|
33
33
|
constructor(pdfParams: PuppeteerParameters);
|
|
34
34
|
onModuleDestroy(): Promise<void>;
|
|
35
|
-
getBrowserInstance(args: string[], headless: boolean | 'shell' | undefined): Promise<Browser>;
|
|
36
|
-
createContext(args: string[], headless: boolean | 'shell' | undefined): Promise<BrowserContext>;
|
|
35
|
+
getBrowserInstance(args: string[], headless: boolean | 'shell' | undefined, executablePathBin: string | undefined): Promise<Browser>;
|
|
36
|
+
createContext(args: string[], headless: boolean | 'shell' | undefined, executablePath?: string): Promise<BrowserContext>;
|
|
37
37
|
markJobStarted(): void;
|
|
38
38
|
markJobFinished(): Promise<void>;
|
|
39
39
|
recycleBrowserIfNeeded(): Promise<void>;
|
|
@@ -174,6 +174,7 @@ interface PuppeteerParameters {
|
|
|
174
174
|
useLockedBrowser?: boolean;
|
|
175
175
|
browserInstallBaseUrl?: string;
|
|
176
176
|
extraPuppeteerArgs?: string[];
|
|
177
|
+
executablePath?: string;
|
|
177
178
|
cleanupBrowserCacheOnExit?: boolean;
|
|
178
179
|
}
|
|
179
180
|
|
package/dist/index.d.ts
CHANGED
|
@@ -32,8 +32,8 @@ declare class BrowserService implements OnModuleDestroy {
|
|
|
32
32
|
private buildId;
|
|
33
33
|
constructor(pdfParams: PuppeteerParameters);
|
|
34
34
|
onModuleDestroy(): Promise<void>;
|
|
35
|
-
getBrowserInstance(args: string[], headless: boolean | 'shell' | undefined): Promise<Browser>;
|
|
36
|
-
createContext(args: string[], headless: boolean | 'shell' | undefined): Promise<BrowserContext>;
|
|
35
|
+
getBrowserInstance(args: string[], headless: boolean | 'shell' | undefined, executablePathBin: string | undefined): Promise<Browser>;
|
|
36
|
+
createContext(args: string[], headless: boolean | 'shell' | undefined, executablePath?: string): Promise<BrowserContext>;
|
|
37
37
|
markJobStarted(): void;
|
|
38
38
|
markJobFinished(): Promise<void>;
|
|
39
39
|
recycleBrowserIfNeeded(): Promise<void>;
|
|
@@ -174,6 +174,7 @@ interface PuppeteerParameters {
|
|
|
174
174
|
useLockedBrowser?: boolean;
|
|
175
175
|
browserInstallBaseUrl?: string;
|
|
176
176
|
extraPuppeteerArgs?: string[];
|
|
177
|
+
executablePath?: string;
|
|
177
178
|
cleanupBrowserCacheOnExit?: boolean;
|
|
178
179
|
}
|
|
179
180
|
|
package/dist/index.js
CHANGED
|
@@ -2683,9 +2683,9 @@ var BrowserService = class {
|
|
|
2683
2683
|
}
|
|
2684
2684
|
await this.cleanupCacheBestEffort();
|
|
2685
2685
|
}
|
|
2686
|
-
async getBrowserInstance(args, headless) {
|
|
2686
|
+
async getBrowserInstance(args, headless, executablePathBin) {
|
|
2687
2687
|
if (!this._browserInstance?.connected) {
|
|
2688
|
-
const executablePath = await this.getExecutablePath();
|
|
2688
|
+
const executablePath = executablePathBin ?? await this.getExecutablePath();
|
|
2689
2689
|
this._browserInstance = await (0, import_puppeteer.launch)({
|
|
2690
2690
|
executablePath,
|
|
2691
2691
|
headless,
|
|
@@ -2697,8 +2697,8 @@ var BrowserService = class {
|
|
|
2697
2697
|
}
|
|
2698
2698
|
return this._browserInstance;
|
|
2699
2699
|
}
|
|
2700
|
-
async createContext(args, headless) {
|
|
2701
|
-
const browser = await this.getBrowserInstance(args, headless);
|
|
2700
|
+
async createContext(args, headless, executablePath) {
|
|
2701
|
+
const browser = await this.getBrowserInstance(args, headless, executablePath);
|
|
2702
2702
|
return await browser.createBrowserContext();
|
|
2703
2703
|
}
|
|
2704
2704
|
markJobStarted() {
|
|
@@ -4337,6 +4337,7 @@ var PuppeteerService = class {
|
|
|
4337
4337
|
import_common8.Logger.warn("Using `chromiumRevision` is no longer supported since the puppeteer update.");
|
|
4338
4338
|
}
|
|
4339
4339
|
const headless = mergePuppeteerOptions.headless ?? true;
|
|
4340
|
+
const executablePath = mergePuppeteerOptions.executablePath || void 0;
|
|
4340
4341
|
const args = mergePuppeteerOptions.extraPuppeteerArgs || [
|
|
4341
4342
|
"--autoplay-policy=user-gesture-required",
|
|
4342
4343
|
"--disable-background-networking",
|
|
@@ -4378,7 +4379,7 @@ var PuppeteerService = class {
|
|
|
4378
4379
|
this.browserService.markJobStarted();
|
|
4379
4380
|
let context = null;
|
|
4380
4381
|
try {
|
|
4381
|
-
context = await this.browserService.createContext(args, headless);
|
|
4382
|
+
context = await this.browserService.createContext(args, headless, executablePath);
|
|
4382
4383
|
const page = await context.newPage();
|
|
4383
4384
|
const pdfOptions = mergePuppeteerOptions.pdfOptions ?? {
|
|
4384
4385
|
format: "A4"
|
package/dist/index.mjs
CHANGED
|
@@ -2666,9 +2666,9 @@ var BrowserService = class {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
await this.cleanupCacheBestEffort();
|
|
2668
2668
|
}
|
|
2669
|
-
async getBrowserInstance(args, headless) {
|
|
2669
|
+
async getBrowserInstance(args, headless, executablePathBin) {
|
|
2670
2670
|
if (!this._browserInstance?.connected) {
|
|
2671
|
-
const executablePath = await this.getExecutablePath();
|
|
2671
|
+
const executablePath = executablePathBin ?? await this.getExecutablePath();
|
|
2672
2672
|
this._browserInstance = await launch({
|
|
2673
2673
|
executablePath,
|
|
2674
2674
|
headless,
|
|
@@ -2680,8 +2680,8 @@ var BrowserService = class {
|
|
|
2680
2680
|
}
|
|
2681
2681
|
return this._browserInstance;
|
|
2682
2682
|
}
|
|
2683
|
-
async createContext(args, headless) {
|
|
2684
|
-
const browser = await this.getBrowserInstance(args, headless);
|
|
2683
|
+
async createContext(args, headless, executablePath) {
|
|
2684
|
+
const browser = await this.getBrowserInstance(args, headless, executablePath);
|
|
2685
2685
|
return await browser.createBrowserContext();
|
|
2686
2686
|
}
|
|
2687
2687
|
markJobStarted() {
|
|
@@ -4320,6 +4320,7 @@ var PuppeteerService = class {
|
|
|
4320
4320
|
Logger2.warn("Using `chromiumRevision` is no longer supported since the puppeteer update.");
|
|
4321
4321
|
}
|
|
4322
4322
|
const headless = mergePuppeteerOptions.headless ?? true;
|
|
4323
|
+
const executablePath = mergePuppeteerOptions.executablePath || void 0;
|
|
4323
4324
|
const args = mergePuppeteerOptions.extraPuppeteerArgs || [
|
|
4324
4325
|
"--autoplay-policy=user-gesture-required",
|
|
4325
4326
|
"--disable-background-networking",
|
|
@@ -4361,7 +4362,7 @@ var PuppeteerService = class {
|
|
|
4361
4362
|
this.browserService.markJobStarted();
|
|
4362
4363
|
let context = null;
|
|
4363
4364
|
try {
|
|
4364
|
-
context = await this.browserService.createContext(args, headless);
|
|
4365
|
+
context = await this.browserService.createContext(args, headless, executablePath);
|
|
4365
4366
|
const page = await context.newPage();
|
|
4366
4367
|
const pdfOptions = mergePuppeteerOptions.pdfOptions ?? {
|
|
4367
4368
|
format: "A4"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shad0wz7/nestjs-pdf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A NestJS library for generating PDFs with Puppeteer and Handlebars.",
|
|
5
5
|
"author": "Emmanuel Boisset",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,55 +56,55 @@
|
|
|
56
56
|
"deepmerge-ts": "^7.1.5",
|
|
57
57
|
"p-limit": "^7.3.0",
|
|
58
58
|
"pdf-lib": "^1.17.1",
|
|
59
|
-
"pdfjs-dist": "^
|
|
59
|
+
"pdfjs-dist": "^6.0.227",
|
|
60
60
|
"puppeteer": "^25.1.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@eslint/eslintrc": "^3.3.5",
|
|
64
64
|
"@eslint/js": "^10.0.1",
|
|
65
|
-
"@nestjs/cli": "^11.0.
|
|
65
|
+
"@nestjs/cli": "^11.0.23",
|
|
66
66
|
"@nestjs/config": "^4.0.4",
|
|
67
|
-
"@nestjs/platform-express": "^11.1.
|
|
67
|
+
"@nestjs/platform-express": "^11.1.27",
|
|
68
68
|
"@nestjs/schematics": "^11.1.0",
|
|
69
|
-
"@nestjs/testing": "^11.1.
|
|
70
|
-
"@swc/core": "^1.15.
|
|
69
|
+
"@nestjs/testing": "^11.1.27",
|
|
70
|
+
"@swc/core": "^1.15.41",
|
|
71
71
|
"@types/ejs": "^3.1.5",
|
|
72
72
|
"@types/express": "^5.0.6",
|
|
73
73
|
"@types/jest": "^30.0.0",
|
|
74
74
|
"@types/mjml": "^5.0.0",
|
|
75
75
|
"@types/mjml-core": "^5.0.0",
|
|
76
76
|
"@types/mustache": "^4.2.6",
|
|
77
|
-
"@types/node": "^
|
|
77
|
+
"@types/node": "^26.0.0",
|
|
78
78
|
"@types/nunjucks": "^3.2.6",
|
|
79
79
|
"@types/pug": "^2.0.10",
|
|
80
80
|
"@types/supertest": "^7.2.0",
|
|
81
|
-
"eslint": "^10.
|
|
81
|
+
"eslint": "^10.5.0",
|
|
82
82
|
"eslint-config-prettier": "^10.1.8",
|
|
83
|
-
"eslint-plugin-prettier": "^5.5.
|
|
83
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
84
84
|
"globals": "^17.6.0",
|
|
85
85
|
"husky": "^9.1.7",
|
|
86
86
|
"jest": "^30.4.2",
|
|
87
|
-
"prettier": "^3.8.
|
|
87
|
+
"prettier": "^3.8.4",
|
|
88
88
|
"reflect-metadata": "^0.2.2",
|
|
89
89
|
"source-map-support": "^0.5.21",
|
|
90
90
|
"supertest": "^7.2.2",
|
|
91
|
-
"ts-jest": "^29.4.
|
|
92
|
-
"ts-loader": "^9.
|
|
91
|
+
"ts-jest": "^29.4.11",
|
|
92
|
+
"ts-loader": "^9.6.1",
|
|
93
93
|
"ts-node": "^10.9.2",
|
|
94
94
|
"tsconfig-paths": "^4.2.0",
|
|
95
95
|
"tsup": "^8.5.1",
|
|
96
96
|
"typescript": "^6.0.3",
|
|
97
|
-
"typescript-eslint": "^8.
|
|
97
|
+
"typescript-eslint": "^8.61.1"
|
|
98
98
|
},
|
|
99
99
|
"optionalDependencies": {
|
|
100
100
|
"@gboutte/nestjs-hbs": "^0.2.0",
|
|
101
101
|
"@napi-rs/canvas": "^1.0.0",
|
|
102
102
|
"ejs": "^6.0.1",
|
|
103
103
|
"eta": "^4.6.0",
|
|
104
|
-
"mjml": "^5.
|
|
104
|
+
"mjml": "^5.3.0",
|
|
105
105
|
"mustache": "^4.2.0",
|
|
106
106
|
"nunjucks": "^3.2.4",
|
|
107
|
-
"pug": "^3.0.
|
|
107
|
+
"pug": "^3.0.4"
|
|
108
108
|
},
|
|
109
109
|
"repository": {
|
|
110
110
|
"url": "git+https://github.com/ShadowZ11/nestjs-pdf.git"
|