@pdfme/converter 6.0.6-dev.14 → 6.0.6-dev.17

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.js CHANGED
@@ -1,17 +1,14 @@
1
1
  import { n as pdf2size$1, r as pdf2img$1, t as img2pdf } from "./img2pdf-Ca1yX5Sv.js";
2
2
  import * as pdfjsLib from "pdfjs-dist/legacy/build/pdf.mjs";
3
3
  //#region src/pdfjs-worker.js?worker&url
4
- var pdfjs_worker_default = "" + new URL("assets/pdfjs-worker-ZFAtFmR9.js", import.meta.url).href;
4
+ var pdfjs_worker_default = "" + new URL("assets/pdfjs-worker-DNts7nT2.js", import.meta.url).href;
5
5
  //#endregion
6
6
  //#region src/index.browser.ts
7
7
  var clonePdfData = (pdf) => pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);
8
8
  var loadingTaskMap = /* @__PURE__ */ new WeakMap();
9
9
  var getDocument = async (pdf) => {
10
- if (typeof Worker !== "undefined" && pdfjsLib.GlobalWorkerOptions.workerSrc !== "" + new URL("assets/pdfjs-worker-ZFAtFmR9.js", import.meta.url).href) pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjs_worker_default;
11
- const loadingTask = pdfjsLib.getDocument({
12
- data: clonePdfData(pdf),
13
- isEvalSupported: false
14
- });
10
+ if (typeof Worker !== "undefined" && pdfjsLib.GlobalWorkerOptions.workerSrc !== "" + new URL("assets/pdfjs-worker-DNts7nT2.js", import.meta.url).href) pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjs_worker_default;
11
+ const loadingTask = pdfjsLib.getDocument({ data: clonePdfData(pdf) });
15
12
  const document = await loadingTask.promise;
16
13
  loadingTaskMap.set(document, { destroy: () => loadingTask.destroy() });
17
14
  return document;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.browser.ts"],"sourcesContent":["import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';\nimport { pdf2img as _pdf2img, Pdf2ImgOptions } from './pdf2img.js';\nimport { pdf2size as _pdf2size, Pdf2SizeOptions } from './pdf2size.js';\nimport workerSrc from './pdfjs-worker.js?worker&url';\n\nconst clonePdfData = (pdf: ArrayBuffer | Uint8Array) =>\n pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);\n\nconst loadingTaskMap = new WeakMap<object, { destroy: () => Promise<void> }>();\n\nconst getDocument = async (pdf: ArrayBuffer | Uint8Array) => {\n if (typeof Worker !== 'undefined' && pdfjsLib.GlobalWorkerOptions.workerSrc !== workerSrc) {\n pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;\n }\n\n const loadingTask = pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n isEvalSupported: false,\n });\n const document = await loadingTask.promise;\n loadingTaskMap.set(document, { destroy: () => loadingTask.destroy() });\n return document;\n};\n\nconst destroyDocument = async (document: object) => {\n const loadingTask = loadingTaskMap.get(document);\n loadingTaskMap.delete(document);\n await loadingTask?.destroy();\n};\n\nfunction dataURLToArrayBuffer(dataURL: string): ArrayBuffer {\n // Split out the actual base64 string from the data URL scheme\n const base64String = dataURL.split(',')[1];\n\n // Decode the Base64 string to get the binary data\n const byteString = atob(base64String);\n\n // Create a typed array from the binary string\n const arrayBuffer = new ArrayBuffer(byteString.length);\n const uintArray = new Uint8Array(arrayBuffer);\n\n for (let i = 0; i < byteString.length; i++) {\n uintArray[i] = byteString.charCodeAt(i);\n }\n\n return arrayBuffer;\n}\n\nexport const pdf2img = async (\n pdf: ArrayBuffer | Uint8Array,\n options: Pdf2ImgOptions = {},\n): Promise<ArrayBuffer[]> =>\n _pdf2img(pdf, options, {\n getDocument,\n destroyDocument,\n createCanvas: (width, height) => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n },\n canvasToArrayBuffer: (canvas, imageType) => {\n // Using type assertion to handle the canvas method\n const dataUrl = (canvas as HTMLCanvasElement).toDataURL(`image/${imageType}`);\n return dataURLToArrayBuffer(dataUrl);\n },\n });\n\nexport const pdf2size = async (pdf: ArrayBuffer | Uint8Array, options: Pdf2SizeOptions = {}) =>\n _pdf2size(pdf, options, {\n getDocument,\n destroyDocument,\n });\n\nexport { img2pdf } from './img2pdf.js';\n"],"mappings":";;;;;;AAKA,IAAM,gBAAgB,QACpB,eAAe,aAAa,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,IAAI;AAEvE,IAAM,iCAAiB,IAAI,SAAmD;AAE9E,IAAM,cAAc,OAAO,QAAkC;AAC3D,KAAI,OAAO,WAAW,eAAe,SAAS,oBAAoB,cAAA,KAAA,IAAA,IAAA,mCAAA,OAAA,KAAA,IAAA,CAAA,KAChE,UAAS,oBAAoB,YAAY;CAG3C,MAAM,cAAc,SAAS,YAAY;EACvC,MAAM,aAAa,IAAI;EACvB,iBAAiB;EAClB,CAAC;CACF,MAAM,WAAW,MAAM,YAAY;AACnC,gBAAe,IAAI,UAAU,EAAE,eAAe,YAAY,SAAS,EAAE,CAAC;AACtE,QAAO;;AAGT,IAAM,kBAAkB,OAAO,aAAqB;CAClD,MAAM,cAAc,eAAe,IAAI,SAAS;AAChD,gBAAe,OAAO,SAAS;AAC/B,OAAM,aAAa,SAAS;;AAG9B,SAAS,qBAAqB,SAA8B;CAE1D,MAAM,eAAe,QAAQ,MAAM,IAAI,CAAC;CAGxC,MAAM,aAAa,KAAK,aAAa;CAGrC,MAAM,cAAc,IAAI,YAAY,WAAW,OAAO;CACtD,MAAM,YAAY,IAAI,WAAW,YAAY;AAE7C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,WAAU,KAAK,WAAW,WAAW,EAAE;AAGzC,QAAO;;AAGT,IAAa,UAAU,OACrB,KACA,UAA0B,EAAE,KAE5B,UAAS,KAAK,SAAS;CACrB;CACA;CACA,eAAe,OAAO,WAAW;EAC/B,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,SAAO,QAAQ;AACf,SAAO,SAAS;AAChB,SAAO;;CAET,sBAAsB,QAAQ,cAAc;AAG1C,SAAO,qBADU,OAA6B,UAAU,SAAS,YACrC,CAAQ;;CAEvC,CAAC;AAEJ,IAAa,WAAW,OAAO,KAA+B,UAA2B,EAAE,KACzF,WAAU,KAAK,SAAS;CACtB;CACA;CACD,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.browser.ts"],"sourcesContent":["import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';\nimport { pdf2img as _pdf2img, Pdf2ImgOptions } from './pdf2img.js';\nimport { pdf2size as _pdf2size, Pdf2SizeOptions } from './pdf2size.js';\nimport workerSrc from './pdfjs-worker.js?worker&url';\n\nconst clonePdfData = (pdf: ArrayBuffer | Uint8Array) =>\n pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);\n\nconst loadingTaskMap = new WeakMap<object, { destroy: () => Promise<void> }>();\n\nconst getDocument = async (pdf: ArrayBuffer | Uint8Array) => {\n if (typeof Worker !== 'undefined' && pdfjsLib.GlobalWorkerOptions.workerSrc !== workerSrc) {\n pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;\n }\n\n const loadingTask = pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n });\n const document = await loadingTask.promise;\n loadingTaskMap.set(document, { destroy: () => loadingTask.destroy() });\n return document;\n};\n\nconst destroyDocument = async (document: object) => {\n const loadingTask = loadingTaskMap.get(document);\n loadingTaskMap.delete(document);\n await loadingTask?.destroy();\n};\n\nfunction dataURLToArrayBuffer(dataURL: string): ArrayBuffer {\n // Split out the actual base64 string from the data URL scheme\n const base64String = dataURL.split(',')[1];\n\n // Decode the Base64 string to get the binary data\n const byteString = atob(base64String);\n\n // Create a typed array from the binary string\n const arrayBuffer = new ArrayBuffer(byteString.length);\n const uintArray = new Uint8Array(arrayBuffer);\n\n for (let i = 0; i < byteString.length; i++) {\n uintArray[i] = byteString.charCodeAt(i);\n }\n\n return arrayBuffer;\n}\n\nexport const pdf2img = async (\n pdf: ArrayBuffer | Uint8Array,\n options: Pdf2ImgOptions = {},\n): Promise<ArrayBuffer[]> =>\n _pdf2img(pdf, options, {\n getDocument,\n destroyDocument,\n createCanvas: (width, height) => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n },\n canvasToArrayBuffer: (canvas, imageType) => {\n // Using type assertion to handle the canvas method\n const dataUrl = (canvas as HTMLCanvasElement).toDataURL(`image/${imageType}`);\n return dataURLToArrayBuffer(dataUrl);\n },\n });\n\nexport const pdf2size = async (pdf: ArrayBuffer | Uint8Array, options: Pdf2SizeOptions = {}) =>\n _pdf2size(pdf, options, {\n getDocument,\n destroyDocument,\n });\n\nexport { img2pdf } from './img2pdf.js';\n"],"mappings":";;;;;;AAKA,IAAM,gBAAgB,QACpB,eAAe,aAAa,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,IAAI;AAEvE,IAAM,iCAAiB,IAAI,SAAmD;AAE9E,IAAM,cAAc,OAAO,QAAkC;AAC3D,KAAI,OAAO,WAAW,eAAe,SAAS,oBAAoB,cAAA,KAAA,IAAA,IAAA,mCAAA,OAAA,KAAA,IAAA,CAAA,KAChE,UAAS,oBAAoB,YAAY;CAG3C,MAAM,cAAc,SAAS,YAAY,EACvC,MAAM,aAAa,IAAI,EACxB,CAAC;CACF,MAAM,WAAW,MAAM,YAAY;AACnC,gBAAe,IAAI,UAAU,EAAE,eAAe,YAAY,SAAS,EAAE,CAAC;AACtE,QAAO;;AAGT,IAAM,kBAAkB,OAAO,aAAqB;CAClD,MAAM,cAAc,eAAe,IAAI,SAAS;AAChD,gBAAe,OAAO,SAAS;AAC/B,OAAM,aAAa,SAAS;;AAG9B,SAAS,qBAAqB,SAA8B;CAE1D,MAAM,eAAe,QAAQ,MAAM,IAAI,CAAC;CAGxC,MAAM,aAAa,KAAK,aAAa;CAGrC,MAAM,cAAc,IAAI,YAAY,WAAW,OAAO;CACtD,MAAM,YAAY,IAAI,WAAW,YAAY;AAE7C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,WAAU,KAAK,WAAW,WAAW,EAAE;AAGzC,QAAO;;AAGT,IAAa,UAAU,OACrB,KACA,UAA0B,EAAE,KAE5B,UAAS,KAAK,SAAS;CACrB;CACA;CACA,eAAe,OAAO,WAAW;EAC/B,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,SAAO,QAAQ;AACf,SAAO,SAAS;AAChB,SAAO;;CAET,sBAAsB,QAAQ,cAAc;AAG1C,SAAO,qBADU,OAA6B,UAAU,SAAS,YACrC,CAAQ;;CAEvC,CAAC;AAEJ,IAAa,WAAW,OAAO,KAA+B,UAA2B,EAAE,KACzF,WAAU,KAAK,SAAS;CACtB;CACA;CACD,CAAC"}
@@ -14,7 +14,6 @@ var pdf2img = async (pdf, options = {}) => {
14
14
  return pdf2img$1(pdf, options, {
15
15
  getDocument: (pdf) => pdfjsLib.getDocument({
16
16
  data: clonePdfData(pdf),
17
- isEvalSupported: false,
18
17
  wasmUrl: pdfJsWasmUrl
19
18
  }).promise,
20
19
  createCanvas: (width, height) => createCanvas(width, height),
@@ -30,7 +29,6 @@ var pdf2img = async (pdf, options = {}) => {
30
29
  var pdf2size = async (pdf, options = {}) => {
31
30
  return pdf2size$1(pdf, options, { getDocument: (pdf) => pdfjsLib.getDocument({
32
31
  data: clonePdfData(pdf),
33
- isEvalSupported: false,
34
32
  wasmUrl: pdfJsWasmUrl
35
33
  }).promise });
36
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.node.js","names":[],"sources":["../src/pdfjs.node.ts","../src/index.node.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nconst require = createRequire(import.meta.url);\nconst pdfJsDistRoot = dirname(require.resolve('pdfjs-dist/package.json'));\n\nexport const getPdfJsWasmUrl = (): string => join(pdfJsDistRoot, 'wasm/');\n","import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';\nimport { Canvas, createCanvas } from '@napi-rs/canvas';\nimport { pdf2img as _pdf2img, Pdf2ImgOptions } from './pdf2img.js';\nimport { pdf2size as _pdf2size, Pdf2SizeOptions } from './pdf2size.js';\nimport { getPdfJsWasmUrl } from './pdfjs.node.js';\n\nconst clonePdfData = (pdf: ArrayBuffer | Uint8Array) =>\n pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);\nconst pdfJsWasmUrl = getPdfJsWasmUrl();\n\nexport const pdf2img = async (\n pdf: ArrayBuffer | Uint8Array,\n options: Pdf2ImgOptions = {},\n): Promise<ArrayBuffer[]> => {\n return _pdf2img(pdf, options, {\n getDocument: (pdf) =>\n pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n isEvalSupported: false,\n wasmUrl: pdfJsWasmUrl,\n }).promise,\n createCanvas: (width, height) => createCanvas(width, height) as unknown as HTMLCanvasElement,\n canvasToArrayBuffer: (canvas, imageType) => {\n const nodeCanvas = canvas as unknown as Canvas;\n const buffer =\n imageType === 'png' ? nodeCanvas.toBuffer('image/png') : nodeCanvas.toBuffer('image/jpeg');\n const arrayBuffer = new ArrayBuffer(buffer.byteLength);\n new Uint8Array(arrayBuffer).set(buffer);\n return arrayBuffer;\n },\n });\n};\n\nexport const pdf2size = async (pdf: ArrayBuffer | Uint8Array, options: Pdf2SizeOptions = {}) => {\n return _pdf2size(pdf, options, {\n getDocument: (pdf) =>\n pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n isEvalSupported: false,\n wasmUrl: pdfJsWasmUrl,\n }).promise,\n });\n};\n\nexport { img2pdf } from './img2pdf.js';\n"],"mappings":";;;;;;AAIA,IAAM,gBAAgB,QADN,cAAc,OAAO,KAAK,IACZ,CAAQ,QAAQ,0BAA0B,CAAC;AAEzE,IAAa,wBAAgC,KAAK,eAAe,QAAQ;;;ACAzE,IAAM,gBAAgB,QACpB,eAAe,aAAa,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,IAAI;AACvE,IAAM,eAAe,iBAAiB;AAEtC,IAAa,UAAU,OACrB,KACA,UAA0B,EAAE,KACD;AAC3B,QAAO,UAAS,KAAK,SAAS;EAC5B,cAAc,QACZ,SAAS,YAAY;GACnB,MAAM,aAAa,IAAI;GACvB,iBAAiB;GACjB,SAAS;GACV,CAAC,CAAC;EACL,eAAe,OAAO,WAAW,aAAa,OAAO,OAAO;EAC5D,sBAAsB,QAAQ,cAAc;GAC1C,MAAM,aAAa;GACnB,MAAM,SACJ,cAAc,QAAQ,WAAW,SAAS,YAAY,GAAG,WAAW,SAAS,aAAa;GAC5F,MAAM,cAAc,IAAI,YAAY,OAAO,WAAW;AACtD,OAAI,WAAW,YAAY,CAAC,IAAI,OAAO;AACvC,UAAO;;EAEV,CAAC;;AAGJ,IAAa,WAAW,OAAO,KAA+B,UAA2B,EAAE,KAAK;AAC9F,QAAO,WAAU,KAAK,SAAS,EAC7B,cAAc,QACZ,SAAS,YAAY;EACnB,MAAM,aAAa,IAAI;EACvB,iBAAiB;EACjB,SAAS;EACV,CAAC,CAAC,SACN,CAAC"}
1
+ {"version":3,"file":"index.node.js","names":[],"sources":["../src/pdfjs.node.ts","../src/index.node.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nconst require = createRequire(import.meta.url);\nconst pdfJsDistRoot = dirname(require.resolve('pdfjs-dist/package.json'));\n\nexport const getPdfJsWasmUrl = (): string => join(pdfJsDistRoot, 'wasm/');\n","import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';\nimport { Canvas, createCanvas } from '@napi-rs/canvas';\nimport { pdf2img as _pdf2img, Pdf2ImgOptions } from './pdf2img.js';\nimport { pdf2size as _pdf2size, Pdf2SizeOptions } from './pdf2size.js';\nimport { getPdfJsWasmUrl } from './pdfjs.node.js';\n\nconst clonePdfData = (pdf: ArrayBuffer | Uint8Array) =>\n pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);\nconst pdfJsWasmUrl = getPdfJsWasmUrl();\n\nexport const pdf2img = async (\n pdf: ArrayBuffer | Uint8Array,\n options: Pdf2ImgOptions = {},\n): Promise<ArrayBuffer[]> => {\n return _pdf2img(pdf, options, {\n getDocument: (pdf) =>\n pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n wasmUrl: pdfJsWasmUrl,\n }).promise,\n createCanvas: (width, height) => createCanvas(width, height) as unknown as HTMLCanvasElement,\n canvasToArrayBuffer: (canvas, imageType) => {\n const nodeCanvas = canvas as unknown as Canvas;\n const buffer =\n imageType === 'png' ? nodeCanvas.toBuffer('image/png') : nodeCanvas.toBuffer('image/jpeg');\n const arrayBuffer = new ArrayBuffer(buffer.byteLength);\n new Uint8Array(arrayBuffer).set(buffer);\n return arrayBuffer;\n },\n });\n};\n\nexport const pdf2size = async (pdf: ArrayBuffer | Uint8Array, options: Pdf2SizeOptions = {}) => {\n return _pdf2size(pdf, options, {\n getDocument: (pdf) =>\n pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n wasmUrl: pdfJsWasmUrl,\n }).promise,\n });\n};\n\nexport { img2pdf } from './img2pdf.js';\n"],"mappings":";;;;;;AAIA,IAAM,gBAAgB,QADN,cAAc,OAAO,KAAK,IACZ,CAAQ,QAAQ,0BAA0B,CAAC;AAEzE,IAAa,wBAAgC,KAAK,eAAe,QAAQ;;;ACAzE,IAAM,gBAAgB,QACpB,eAAe,aAAa,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,IAAI;AACvE,IAAM,eAAe,iBAAiB;AAEtC,IAAa,UAAU,OACrB,KACA,UAA0B,EAAE,KACD;AAC3B,QAAO,UAAS,KAAK,SAAS;EAC5B,cAAc,QACZ,SAAS,YAAY;GACnB,MAAM,aAAa,IAAI;GACvB,SAAS;GACV,CAAC,CAAC;EACL,eAAe,OAAO,WAAW,aAAa,OAAO,OAAO;EAC5D,sBAAsB,QAAQ,cAAc;GAC1C,MAAM,aAAa;GACnB,MAAM,SACJ,cAAc,QAAQ,WAAW,SAAS,YAAY,GAAG,WAAW,SAAS,aAAa;GAC5F,MAAM,cAAc,IAAI,YAAY,OAAO,WAAW;AACtD,OAAI,WAAW,YAAY,CAAC,IAAI,OAAO;AACvC,UAAO;;EAEV,CAAC;;AAGJ,IAAa,WAAW,OAAO,KAA+B,UAA2B,EAAE,KAAK;AAC9F,QAAO,WAAU,KAAK,SAAS,EAC7B,cAAc,QACZ,SAAS,YAAY;EACnB,MAAM,aAAa,IAAI;EACvB,SAAS;EACV,CAAC,CAAC,SACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/converter",
3
- "version": "6.0.6-dev.14",
3
+ "version": "6.0.6-dev.17",
4
4
  "description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
5
5
  "keywords": [
6
6
  "pdf",
@@ -49,10 +49,10 @@
49
49
  "test": "vitest run --config ../../vitest.config.ts"
50
50
  },
51
51
  "dependencies": {
52
- "@napi-rs/canvas": "^0.1.99",
52
+ "@napi-rs/canvas": "^0.1.100",
53
53
  "@pdfme/common": "*",
54
54
  "@pdfme/pdf-lib": "*",
55
- "pdfjs-dist": "^5.6.205"
55
+ "pdfjs-dist": "^5.7.284"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@pdfme/generator": "*"