afpp 1.2.0 → 1.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/dist/index.js CHANGED
@@ -1,68 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pdf2string = void 0;
4
- const promises_1 = require("node:fs/promises");
5
- const parsePdfFileBuffer = async (options) => import('pdfjs-dist/legacy/build/pdf.mjs').then(async (pdfjsLib) => {
6
- const loadingTask = pdfjsLib.getDocument({
7
- ...options,
8
- verbosity: 0, // TODO enable for debug
9
- });
10
- const pdfDocument = await loadingTask.promise;
11
- const { numPages } = pdfDocument;
12
- const pageContents = new Array(numPages).fill('');
13
- const pagePromises = [];
14
- for (let pageNum = 1; pageNum <= numPages; pageNum += 1) {
15
- pagePromises.push(pdfDocument.getPage(pageNum).then(async (page) => {
16
- const textContent = await page.getTextContent({
17
- includeMarkedContent: false,
18
- });
19
- // ? Type assertion of items to TextItem[] should be safe because {includeMarkedContent: false}
20
- const items = textContent.items;
21
- if (items.length === 0) {
22
- pageContents[pageNum - 1] = '';
23
- }
24
- else {
25
- const pageText = items.map((item) => item.str || '').join(' ');
26
- pageContents[pageNum - 1] = pageText;
27
- }
28
- }));
29
- }
30
- await Promise.all(pagePromises);
31
- return pageContents;
32
- });
33
- /**
34
- * Converts a PDF file from various input formats (Buffer, Uint8Array, string path, or URL) to a string.
35
- *
36
- * @async
37
- * @function pdf2string
38
- *
39
- * @param {Buffer|Uint8Array|string|URL} input - The PDF source, which can be a file path, URL, Buffer, or Uint8Array.
40
- * @param {Object} [options] - Optional parsing options for customizing the PDF parsing process.
41
- * @param {string} [options.password] - The password for encrypted PDF files, if required.
42
- *
43
- * @since — v1.0.0
44
- *
45
- * @returns {Promise<string>} - A promise that resolves to the string representation of the PDF content.
46
- *
47
- * @throws {Error} Throws an error if the input type is invalid.
48
- */
49
- const pdf2string = async (input, options) => {
50
- if (typeof input === 'string') {
51
- const fileBuffer = await (0, promises_1.readFile)(input, {});
52
- const data = new Uint8Array(fileBuffer);
53
- return parsePdfFileBuffer({ data, ...options });
54
- }
55
- if (Buffer.isBuffer(input)) {
56
- const data = new Uint8Array(input);
57
- return parsePdfFileBuffer({ data, ...options });
58
- }
59
- if (input instanceof Uint8Array) {
60
- return parsePdfFileBuffer({ data: input, ...options });
61
- }
62
- if (input instanceof URL) {
63
- return parsePdfFileBuffer({ url: input, ...options });
64
- }
65
- throw new Error(`Invalid source type: ${typeof input}`);
66
- };
67
- exports.pdf2string = pdf2string;
3
+ exports.pdf2string = exports.pdf2image = void 0;
4
+ var pdf2image_1 = require("#afpp/src/pdf2image");
5
+ Object.defineProperty(exports, "pdf2image", { enumerable: true, get: function () { return pdf2image_1.pdf2image; } });
6
+ var pdf2string_1 = require("#afpp/src/pdf2string");
7
+ Object.defineProperty(exports, "pdf2string", { enumerable: true, get: function () { return pdf2string_1.pdf2string; } });
68
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAQ5C,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAA+B,EAAE,EAAE,CACnE,MAAM,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IAChE,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACvC,GAAG,OAAO;QACV,SAAS,EAAE,CAAC,EAAE,wBAAwB;KACvC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC;IAE9C,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;IACjC,MAAM,YAAY,GAAa,IAAI,KAAK,CAAS,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,MAAM,YAAY,GAAmC,EAAE,CAAC;IAExD,KAAK,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AAC;IAClD,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,kBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACzB,OAAO,kBAAkB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEO,gCAAU"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAClB,mDAAkD;AAAzC,wGAAA,UAAU,OAAA"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pdf2image = void 0;
4
+ /* eslint-disable no-underscore-dangle */
5
+ const promises_1 = require("node:fs/promises");
6
+ const canvas_1 = require("canvas");
7
+ const parsePdfFileBuffer = async (options) => import('pdfjs-dist/legacy/build/pdf.mjs').then(async (pdfjsLib) => {
8
+ const loadingTask = pdfjsLib.getDocument({
9
+ ...options,
10
+ verbosity: 0, // TODO enable for debug
11
+ });
12
+ const pdfDocument = await loadingTask.promise;
13
+ // get a canvas factory method from pdfjs-dist
14
+ const { canvasFactory } = pdfDocument._transport;
15
+ if (!canvasFactory) {
16
+ throw new Error('Get canvas error, check current node version');
17
+ }
18
+ const { numPages } = pdfDocument;
19
+ const pageContents = new Array(numPages).fill(Buffer.from(''));
20
+ const pagePromises = [];
21
+ for (let pageNum = 1; pageNum <= numPages; pageNum += 1) {
22
+ pagePromises.push(pdfDocument.getPage(pageNum).then(async (page) => {
23
+ const viewport = page.getViewport({ scale: 1.0 });
24
+ const canvas = (0, canvas_1.createCanvas)(viewport.width, viewport.height);
25
+ const context = canvas.getContext('2d');
26
+ await page.render({ canvasContext: context, viewport }).promise;
27
+ const imageBuffer = canvas.toBuffer();
28
+ pageContents[pageNum - 1] = imageBuffer;
29
+ }));
30
+ }
31
+ await Promise.all(pagePromises);
32
+ return pageContents;
33
+ });
34
+ /**
35
+ * Converts a PDF file from various input formats (Buffer, Uint8Array, string path, or URL) to a string.
36
+ *
37
+ * @async
38
+ * @function pdf2string
39
+ *
40
+ * @param {Buffer|Uint8Array|string|URL} input - The PDF source, which can be a file path, URL, Buffer, or Uint8Array.
41
+ * @param {Object} [options] - Optional parsing options for customizing the PDF parsing process.
42
+ * @param {string} [options.password] - The password for encrypted PDF files, if required.
43
+ *
44
+ * @since — v1.0.0
45
+ *
46
+ * @returns {Promise<string>} - A promise that resolves to the string representation of the PDF content.
47
+ *
48
+ * @throws {Error} Throws an error if the input type is invalid.
49
+ */
50
+ const pdf2image = async (input, options) => {
51
+ if (typeof input === 'string') {
52
+ const fileBuffer = await (0, promises_1.readFile)(input, {});
53
+ const data = new Uint8Array(fileBuffer);
54
+ return parsePdfFileBuffer({ data, ...options });
55
+ }
56
+ if (Buffer.isBuffer(input)) {
57
+ const data = new Uint8Array(input);
58
+ return parsePdfFileBuffer({ data, ...options });
59
+ }
60
+ if (input instanceof Uint8Array) {
61
+ return parsePdfFileBuffer({ data: input, ...options });
62
+ }
63
+ if (input instanceof URL) {
64
+ return parsePdfFileBuffer({ url: input, ...options });
65
+ }
66
+ throw new Error(`Invalid source type: ${typeof input}`);
67
+ };
68
+ exports.pdf2image = pdf2image;
69
+ //# sourceMappingURL=pdf2image.js.map
@@ -0,0 +1 @@
1
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AE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AApBW,QAAA,SAAS,aAoBpB"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pdf2string = void 0;
4
+ const promises_1 = require("node:fs/promises");
5
+ const parsePdfFileBuffer = async (options) => import('pdfjs-dist/legacy/build/pdf.mjs').then(async (pdfjsLib) => {
6
+ const loadingTask = pdfjsLib.getDocument({
7
+ ...options,
8
+ verbosity: 0, // TODO enable for debug
9
+ });
10
+ const pdfDocument = await loadingTask.promise;
11
+ const { numPages } = pdfDocument;
12
+ const pageContents = new Array(numPages).fill('');
13
+ const pagePromises = [];
14
+ for (let pageNum = 1; pageNum <= numPages; pageNum += 1) {
15
+ pagePromises.push(pdfDocument.getPage(pageNum).then(async (page) => {
16
+ const textContent = await page.getTextContent({
17
+ includeMarkedContent: false,
18
+ });
19
+ // ? Type assertion of items to TextItem[] should be safe because {includeMarkedContent: false}
20
+ const items = textContent.items;
21
+ if (items.length === 0) {
22
+ pageContents[pageNum - 1] = '';
23
+ }
24
+ else {
25
+ const pageText = items.map((item) => item.str || '').join(' ');
26
+ pageContents[pageNum - 1] = pageText;
27
+ }
28
+ }));
29
+ }
30
+ await Promise.all(pagePromises);
31
+ return pageContents;
32
+ });
33
+ /**
34
+ * Converts a PDF file from various input formats (Buffer, Uint8Array, string path, or URL) to a string.
35
+ *
36
+ * @async
37
+ * @function pdf2string
38
+ *
39
+ * @param {Buffer|Uint8Array|string|URL} input - The PDF source, which can be a file path, URL, Buffer, or Uint8Array.
40
+ * @param {Object} [options] - Optional parsing options for customizing the PDF parsing process.
41
+ * @param {string} [options.password] - The password for encrypted PDF files, if required.
42
+ *
43
+ * @since — v1.0.0
44
+ *
45
+ * @returns {Promise<string>} - A promise that resolves to the string representation of the PDF content.
46
+ *
47
+ * @throws {Error} Throws an error if the input type is invalid.
48
+ */
49
+ const pdf2string = async (input, options) => {
50
+ if (typeof input === 'string') {
51
+ const fileBuffer = await (0, promises_1.readFile)(input, {});
52
+ const data = new Uint8Array(fileBuffer);
53
+ return parsePdfFileBuffer({ data, ...options });
54
+ }
55
+ if (Buffer.isBuffer(input)) {
56
+ const data = new Uint8Array(input);
57
+ return parsePdfFileBuffer({ data, ...options });
58
+ }
59
+ if (input instanceof Uint8Array) {
60
+ return parsePdfFileBuffer({ data: input, ...options });
61
+ }
62
+ if (input instanceof URL) {
63
+ return parsePdfFileBuffer({ url: input, ...options });
64
+ }
65
+ throw new Error(`Invalid source type: ${typeof input}`);
66
+ };
67
+ exports.pdf2string = pdf2string;
68
+ //# sourceMappingURL=pdf2string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf2string.js","sourceRoot":"","sources":["../src/pdf2string.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAQ5C,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAA+B,EAAE,EAAE,CACnE,MAAM,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IAChE,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACvC,GAAG,OAAO;QACV,SAAS,EAAE,CAAC,EAAE,wBAAwB;KACvC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC;IAE9C,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;IACjC,MAAM,YAAY,GAAa,IAAI,KAAK,CAAS,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,MAAM,YAAY,GAAmC,EAAE,CAAC;IAExD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;QACxD,YAAY,CAAC,IAAI,CACf,WAAW,CA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AAK,CAAC,CAAC;QACnC,OAAO,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,kBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACzB,OAAO,kBAAkB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AApBW,QAAA,UAAU,cAoBrB"}
@@ -1,21 +1,2 @@
1
- type ParseOptions = {
2
- password?: string;
3
- };
4
- /**
5
- * Converts a PDF file from various input formats (Buffer, Uint8Array, string path, or URL) to a string.
6
- *
7
- * @async
8
- * @function pdf2string
9
- *
10
- * @param {Buffer|Uint8Array|string|URL} input - The PDF source, which can be a file path, URL, Buffer, or Uint8Array.
11
- * @param {Object} [options] - Optional parsing options for customizing the PDF parsing process.
12
- * @param {string} [options.password] - The password for encrypted PDF files, if required.
13
- *
14
- * @since — v1.0.0
15
- *
16
- * @returns {Promise<string>} - A promise that resolves to the string representation of the PDF content.
17
- *
18
- * @throws {Error} Throws an error if the input type is invalid.
19
- */
20
- declare const pdf2string: (input: Buffer | URL | Uint8Array | string, options?: ParseOptions) => Promise<string[]>;
21
- export { pdf2string };
1
+ export { pdf2image } from '#afpp/src/pdf2image';
2
+ export { pdf2string } from '#afpp/src/pdf2string';
@@ -0,0 +1,21 @@
1
+ type ParseOptions = {
2
+ password?: string;
3
+ };
4
+ /**
5
+ * Converts a PDF file from various input formats (Buffer, Uint8Array, string path, or URL) to a string.
6
+ *
7
+ * @async
8
+ * @function pdf2string
9
+ *
10
+ * @param {Buffer|Uint8Array|string|URL} input - The PDF source, which can be a file path, URL, Buffer, or Uint8Array.
11
+ * @param {Object} [options] - Optional parsing options for customizing the PDF parsing process.
12
+ * @param {string} [options.password] - The password for encrypted PDF files, if required.
13
+ *
14
+ * @since — v1.0.0
15
+ *
16
+ * @returns {Promise<string>} - A promise that resolves to the string representation of the PDF content.
17
+ *
18
+ * @throws {Error} Throws an error if the input type is invalid.
19
+ */
20
+ export declare const pdf2image: (input: Buffer | URL | Uint8Array | string, options?: ParseOptions) => Promise<Buffer[]>;
21
+ export {};
@@ -0,0 +1,21 @@
1
+ type ParseOptions = {
2
+ password?: string;
3
+ };
4
+ /**
5
+ * Converts a PDF file from various input formats (Buffer, Uint8Array, string path, or URL) to a string.
6
+ *
7
+ * @async
8
+ * @function pdf2string
9
+ *
10
+ * @param {Buffer|Uint8Array|string|URL} input - The PDF source, which can be a file path, URL, Buffer, or Uint8Array.
11
+ * @param {Object} [options] - Optional parsing options for customizing the PDF parsing process.
12
+ * @param {string} [options.password] - The password for encrypted PDF files, if required.
13
+ *
14
+ * @since — v1.0.0
15
+ *
16
+ * @returns {Promise<string>} - A promise that resolves to the string representation of the PDF content.
17
+ *
18
+ * @throws {Error} Throws an error if the input type is invalid.
19
+ */
20
+ export declare const pdf2string: (input: Buffer | URL | Uint8Array | string, options?: ParseOptions) => Promise<string[]>;
21
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "afpp",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "another f*cking pdf parser",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -13,8 +13,9 @@
13
13
  "lint": "eslint .",
14
14
  "prebuild": "rm -rf dist",
15
15
  "prepare": "husky",
16
- "test": "NODE_ENV=test npx tsx --test --test-reporter=@voxpelli/node-test-pretty-reporter test/*.test.ts",
17
- "test:coverage": "NODE_ENV=test npx tsx --test --experimental-test-coverage test/*.test.ts",
16
+ "test": "NODE_ENV=test npx tsx --test --test-reporter @voxpelli/node-test-pretty-reporter test/*.test.ts",
17
+ "pretest:coverage": "rm -rf coverage",
18
+ "test:coverage": "NODE_V8_COVERAGE=coverage NODE_ENV=test npx tsx --test --experimental-test-coverage --test-reporter lcov --test-reporter-destination=coverage/lcov.info test/*.test.ts",
18
19
  "typecheck": "tsc -p tsconfig.json --noEmit"
19
20
  },
20
21
  "repository": {
@@ -38,10 +39,6 @@
38
39
  "url": "https://github.com/l2ysho/afpp/issues"
39
40
  },
40
41
  "homepage": "https://github.com/l2ysho/afpp#readme",
41
- "dependencies": {
42
- "pdfjs-dist": "4.6.82",
43
- "typescript": "5.6.2"
44
- },
45
42
  "devDependencies": {
46
43
  "@commitlint/cli": "19.5.0",
47
44
  "@commitlint/config-conventional": "19.5.0",
@@ -64,6 +61,11 @@
64
61
  "husky": "9.1.6",
65
62
  "lint-staged": "15.2.10",
66
63
  "semantic-release": "24.1.1",
67
- "tsx": "4.19.1"
64
+ "tsx": "4.19.1",
65
+ "typescript": "5.6.2"
66
+ },
67
+ "dependencies": {
68
+ "canvas": "2.11.2",
69
+ "pdfjs-dist": "4.6.82"
68
70
  }
69
71
  }