jspdf-dynamo 1.0.8 → 1.0.9

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/dist/index.cjs CHANGED
@@ -62,7 +62,7 @@ __export(index_exports, {
62
62
  module.exports = __toCommonJS(index_exports);
63
63
 
64
64
  // src/models/jsPdfProcessor.ts
65
- var import_jspdf = __toESM(require("jspdf"), 1);
65
+ var jspdfModule = __toESM(require("jspdf"), 1);
66
66
  var fs = __toESM(require("fs"), 1);
67
67
 
68
68
  // src/models/logger.ts
@@ -340,11 +340,18 @@ var JsPdfProcessor = class {
340
340
  };
341
341
  this._logger = logger;
342
342
  const optn = new JsPdfOptions(options);
343
- this._pdfDocument = new import_jspdf.default(optn);
343
+ const jsPDFCtor = jspdfModule && typeof jspdfModule.default === "function" ? jspdfModule.default : jspdfModule && typeof jspdfModule.jsPDF === "function" ? jspdfModule.jsPDF : typeof jspdfModule === "function" ? jspdfModule : void 0;
344
+ if (!jsPDFCtor) {
345
+ throw new Error(
346
+ 'jsPDF constructor not found. Ensure a compatible "jspdf" package is installed.'
347
+ );
348
+ }
349
+ this._pdfDocument = new jsPDFCtor(optn);
350
+ this._pdfDocument.setLineHeightFactor(1);
351
+ this._pdfDocument.setProperties({ creator: "jsPdf-Dynamo" });
344
352
  this.pageSize = optn.pageSize;
345
353
  this.pageOrientation = optn.orientation;
346
354
  this.currentUom = optn.unit;
347
- this._pdfDocument.setLineHeightFactor(1);
348
355
  const now = /* @__PURE__ */ new Date();
349
356
  this._variables.set(
350
357
  "_TIMEHM",
@@ -660,7 +667,8 @@ var JsPdfProcessor = class {
660
667
  this._pdfDocument.setTextColor(this._textColour);
661
668
  }
662
669
  get pageCount() {
663
- return this._pdfDocument ? this._pdfDocument.internal.getNumberOfPages() : -1;
670
+ const internal = this._pdfDocument && this._pdfDocument.internal ? this._pdfDocument.internal : null;
671
+ return internal && typeof internal.getNumberOfPages === "function" ? internal.getNumberOfPages() : -1;
664
672
  }
665
673
  addBookmark(input) {
666
674
  const subs = this.logAndParseCommand(".addBookmark", input);
@@ -1689,9 +1697,6 @@ var JsPdfProcessor = class {
1689
1697
  let { first, rest } = getNextString(subs);
1690
1698
  this.lastResult = "1";
1691
1699
  switch (first.toLocaleLowerCase()) {
1692
- case "application":
1693
- this._pdfDocument.setProperties({ application: rest });
1694
- break;
1695
1700
  case "author":
1696
1701
  this._pdfDocument.setProperties({ author: rest });
1697
1702
  break;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import jsPDF from 'jspdf';
1
+ import { jsPDF } from 'jspdf';
2
2
 
3
3
  interface ILogger {
4
4
  debug: (message: string, args?: any) => void;
@@ -370,7 +370,7 @@ declare class JsPdfDynamo {
370
370
  _processor: JsPdfProcessor;
371
371
  constructor(options?: Partial<IJsPdfOptions>, logger?: ILogger | null);
372
372
  toBlob(): Blob | null;
373
- toBlobUrl(): string | null;
373
+ toBlobUrl(): URL | null;
374
374
  getVariable(variableName: string): string | null;
375
375
  private prepareNewPdf;
376
376
  prepareWrappedString(input: string): string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import jsPDF from 'jspdf';
1
+ import { jsPDF } from 'jspdf';
2
2
 
3
3
  interface ILogger {
4
4
  debug: (message: string, args?: any) => void;
@@ -370,7 +370,7 @@ declare class JsPdfDynamo {
370
370
  _processor: JsPdfProcessor;
371
371
  constructor(options?: Partial<IJsPdfOptions>, logger?: ILogger | null);
372
372
  toBlob(): Blob | null;
373
- toBlobUrl(): string | null;
373
+ toBlobUrl(): URL | null;
374
374
  getVariable(variableName: string): string | null;
375
375
  private prepareNewPdf;
376
376
  prepareWrappedString(input: string): string;
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var __async = (__this, __arguments, generator) => {
33
33
  };
34
34
 
35
35
  // src/models/jsPdfProcessor.ts
36
- import jsPDF from "jspdf";
36
+ import * as jspdfModule from "jspdf";
37
37
  import * as fs from "fs";
38
38
 
39
39
  // src/models/logger.ts
@@ -311,11 +311,18 @@ var JsPdfProcessor = class {
311
311
  };
312
312
  this._logger = logger;
313
313
  const optn = new JsPdfOptions(options);
314
- this._pdfDocument = new jsPDF(optn);
314
+ const jsPDFCtor = jspdfModule && typeof jspdfModule.default === "function" ? jspdfModule.default : jspdfModule && typeof jspdfModule.jsPDF === "function" ? jspdfModule.jsPDF : typeof jspdfModule === "function" ? jspdfModule : void 0;
315
+ if (!jsPDFCtor) {
316
+ throw new Error(
317
+ 'jsPDF constructor not found. Ensure a compatible "jspdf" package is installed.'
318
+ );
319
+ }
320
+ this._pdfDocument = new jsPDFCtor(optn);
321
+ this._pdfDocument.setLineHeightFactor(1);
322
+ this._pdfDocument.setProperties({ creator: "jsPdf-Dynamo" });
315
323
  this.pageSize = optn.pageSize;
316
324
  this.pageOrientation = optn.orientation;
317
325
  this.currentUom = optn.unit;
318
- this._pdfDocument.setLineHeightFactor(1);
319
326
  const now = /* @__PURE__ */ new Date();
320
327
  this._variables.set(
321
328
  "_TIMEHM",
@@ -631,7 +638,8 @@ var JsPdfProcessor = class {
631
638
  this._pdfDocument.setTextColor(this._textColour);
632
639
  }
633
640
  get pageCount() {
634
- return this._pdfDocument ? this._pdfDocument.internal.getNumberOfPages() : -1;
641
+ const internal = this._pdfDocument && this._pdfDocument.internal ? this._pdfDocument.internal : null;
642
+ return internal && typeof internal.getNumberOfPages === "function" ? internal.getNumberOfPages() : -1;
635
643
  }
636
644
  addBookmark(input) {
637
645
  const subs = this.logAndParseCommand(".addBookmark", input);
@@ -1660,9 +1668,6 @@ var JsPdfProcessor = class {
1660
1668
  let { first, rest } = getNextString(subs);
1661
1669
  this.lastResult = "1";
1662
1670
  switch (first.toLocaleLowerCase()) {
1663
- case "application":
1664
- this._pdfDocument.setProperties({ application: rest });
1665
- break;
1666
1671
  case "author":
1667
1672
  this._pdfDocument.setProperties({ author: rest });
1668
1673
  break;
@@ -1,7 +1,7 @@
1
1
  .SetVar CommandName toBlobUrl()
2
2
  .Do CommandHeading
3
3
  .SetVar text This is a browser only method that generates the current PDF as a Blob
4
- .SetVar text %text% and returns a string containing a URL to that Blob. This can be
4
+ .SetVar text %text% and returns the URL to that Blob. This can be
5
5
  .SetVar text %text% used to display the PDF in the current or another browser window.
6
6
  .DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
7
7
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  .SetVar CommandSubHeading Returns
14
14
  .Do CommandSubHeading
15
- .SetVar CommandLine1 A string containing the URL reference to the PDF.
15
+ .SetVar CommandLine1 A URL object that references the PDF.
16
16
  .Do CommandLine2
17
17
 
18
18
  .SetVar CommandSubHeading Example
@@ -10,14 +10,10 @@
10
10
  .SetVar CommandSubHeading Parameters
11
11
  .Do CommandSubHeading
12
12
  .SetVar CommandLine1 Property
13
- .SetVar CommandLine2 One of the following values: Application, Author, Creator, CreationDate, Keywords,
14
- .Do CommandLine2
15
- .SetVar CommandLine2 ModDate, Producer, Subject or Title.
13
+ .SetVar CommandLine2 One of the following values: Author, Creator, Keywords, Subject or Title.
16
14
  .Do CommandLine2
17
15
  .SetVar CommandLine1 Value
18
- .SetVar CommandLine2 The value to set the property to. For CreationDate and ModDate this must
19
- .Do CommandLine2
20
- .SetVar CommandLine2 either be in the format of yyyy-mm-dd or blank.
16
+ .SetVar CommandLine2 The value to set the property to.
21
17
  .Do CommandLine2
22
18
 
23
19
  .SetVar CommandSubHeading Other
@@ -270,5 +270,5 @@
270
270
  .ForEachPage Footer
271
271
 
272
272
  ;.DrawDebugGrid
273
- .SAVEpdF ./documentation/Documentation.pdf
273
+ .SAVEpdF ./Documentation.pdf
274
274
  .WriteLog info Documentation has been generated.
@@ -45,8 +45,9 @@ endobj
45
45
  endobj
46
46
  6 0 obj
47
47
  <<
48
- /Producer (jsPDF 2.5.2)
49
- /CreationDate (D:20241006151126+10'00')
48
+ /Producer (jsPDF 4.1.0)
49
+ /Creator (jsPdf-Dynamo)
50
+ /CreationDate (D:20260205101406+11'00')
50
51
  >>
51
52
  endobj
52
53
  7 0 obj
@@ -66,14 +67,14 @@ xref
66
67
  0000000152 00000 n
67
68
  0000000470 00000 n
68
69
  0000000704 00000 n
69
- 0000000789 00000 n
70
+ 0000000813 00000 n
70
71
  trailer
71
72
  <<
72
73
  /Size 8
73
74
  /Root 7 0 R
74
75
  /Info 6 0 R
75
- /ID [ <A4FE96B1D9C5D34C705DDBFDD4170A74> <A4FE96B1D9C5D34C705DDBFDD4170A74> ]
76
+ /ID [ <6F3B78A493C9BF1EDA9BB278B0829F9E> <6F3B78A493C9BF1EDA9BB278B0829F9E> ]
76
77
  >>
77
78
  startxref
78
- 892
79
+ 916
79
80
  %%EOF
Binary file
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "jspdf-dynamo",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Generate data driven PDFs from dynamic templates",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/SteveCorbett/jsPdf-Dynamo"
10
+ "url": "git+https://github.com/SteveCorbett/jsPdf-Dynamo.git"
11
11
  },
12
12
  "bugs": {
13
13
  "url": "https://github.com/SteveCorbett/jsPdf-Dynamo/issues"
@@ -15,8 +15,8 @@
15
15
  "scripts": {
16
16
  "build": "tsup",
17
17
  "build-docs": "vitest --dir ./documentation run",
18
- "check-exports": "attw --pack . ",
19
- "ci": "npm run test && npm run lint && npm run build && npm run check-format && npm run check-exports ",
18
+ "check-exports": "npm pack && attw \"$(ls *.tgz | head -n 1)\" && rm -f *.tgz",
19
+ "ci": "npm run test && npm run lint && npm run build && npm run check-format && ( [ \"$npm_config_dry_run\" = \"true\" ] && echo \"Skipping check-exports in dry-run\" || npm run check-exports )",
20
20
  "examples": "vitest --dir ./examples run",
21
21
  "format": "prettier --write .",
22
22
  "lint": "tsc",
@@ -51,6 +51,7 @@
51
51
  "files": [
52
52
  "dist",
53
53
  "documentation",
54
+ "Documentation.pdf",
54
55
  "examples",
55
56
  "README.md",
56
57
  "LICENSE"
@@ -1,7 +0,0 @@
1
- ## How to build the documentation
2
-
3
- The documentation for jsPdfDynamo is built using jsPdfDynamo. Once the project dependencies have been restored, run the following command:
4
-
5
- ```
6
- npm run build-docs
7
- ```
@@ -1,22 +0,0 @@
1
- import { expect, it, describe } from "vitest";
2
- import { JsPdfDynamo } from "../src/jsPdfDynamo";
3
- import { Logger } from "tslog";
4
- import { ILogger } from "../src/models/logger";
5
-
6
- describe("Build the documentation", () => {
7
- it("should build", async () => {
8
- const logger: ILogger = new Logger({
9
- name: "jspdf-dynamo",
10
- minLevel: 0,
11
- type: "pretty",
12
- });
13
- const pdfDynamo = new JsPdfDynamo(
14
- { pageSize: "a4", orientation: "portrait" },
15
- logger,
16
- );
17
- await pdfDynamo.processCommands([
18
- ".include ./documentation/documentation.txt",
19
- ]);
20
- expect(true).toBe(true);
21
- });
22
- });