unpdf 0.5.3 → 0.5.4
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.node.cjs +2 -2
- package/dist/index.node.d.cts +2 -2
- package/dist/index.node.d.mts +2 -2
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.mjs +3 -3
- package/dist/index.web.cjs +2 -2
- package/dist/index.web.d.cts +2 -2
- package/dist/index.web.d.mts +2 -2
- package/dist/index.web.d.ts +2 -2
- package/dist/index.web.mjs +3 -3
- package/dist/index.worker.cjs +1 -1
- package/dist/index.worker.d.cts +2 -2
- package/dist/index.worker.d.mts +2 -2
- package/dist/index.worker.d.ts +2 -2
- package/dist/index.worker.mjs +1 -1
- package/dist/shared/{unpdf.cd67d475.mjs → unpdf.3dcacb97.mjs} +3 -2
- package/dist/shared/{unpdf.61a2a4e1.cjs → unpdf.42987ff1.cjs} +6 -10
- package/dist/shared/{unpdf.d3d8f5ac.d.mts → unpdf.6363738c.d.cts} +2 -2
- package/dist/shared/{unpdf.d3d8f5ac.d.cts → unpdf.6363738c.d.mts} +2 -2
- package/dist/shared/{unpdf.d3d8f5ac.d.ts → unpdf.6363738c.d.ts} +2 -2
- package/dist/shared/{unpdf.c7f36e56.mjs → unpdf.ab6a2535.mjs} +6 -10
- package/dist/shared/{unpdf.9511ac30.cjs → unpdf.eba9a3dc.cjs} +3 -2
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const image = require('./shared/unpdf.
|
|
4
|
-
const utils = require('./shared/unpdf.
|
|
3
|
+
const image = require('./shared/unpdf.eba9a3dc.cjs');
|
|
4
|
+
const utils = require('./shared/unpdf.42987ff1.cjs');
|
|
5
5
|
|
|
6
6
|
const getPDFMeta = async (...args) => {
|
|
7
7
|
await utils.resolvePDFJSImports();
|
package/dist/index.node.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.cjs';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.cjs';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.node.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.mjs';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.mjs';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.js';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.js';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
import { r as resolvePDFJSImports } from './shared/unpdf.
|
|
3
|
-
export { d as defineUnPDFConfig, g as getDocumentProxy, a as getResolvedPDFJS } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.3dcacb97.mjs';
|
|
2
|
+
import { r as resolvePDFJSImports } from './shared/unpdf.ab6a2535.mjs';
|
|
3
|
+
export { d as defineUnPDFConfig, g as getDocumentProxy, a as getResolvedPDFJS } from './shared/unpdf.ab6a2535.mjs';
|
|
4
4
|
|
|
5
5
|
const getPDFMeta = async (...args) => {
|
|
6
6
|
await resolvePDFJSImports();
|
package/dist/index.web.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const image = require('./shared/unpdf.
|
|
4
|
-
const utils = require('./shared/unpdf.
|
|
3
|
+
const image = require('./shared/unpdf.eba9a3dc.cjs');
|
|
4
|
+
const utils = require('./shared/unpdf.42987ff1.cjs');
|
|
5
5
|
|
|
6
6
|
const getPDFMeta = async (...args) => {
|
|
7
7
|
await utils.resolvePDFJSImports();
|
package/dist/index.web.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.cjs';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.cjs';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.web.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.mjs';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.mjs';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.js';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.js';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.web.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
import { r as resolvePDFJSImports } from './shared/unpdf.
|
|
3
|
-
export { d as defineUnPDFConfig, g as getDocumentProxy, a as getResolvedPDFJS } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.3dcacb97.mjs';
|
|
2
|
+
import { r as resolvePDFJSImports } from './shared/unpdf.ab6a2535.mjs';
|
|
3
|
+
export { d as defineUnPDFConfig, g as getDocumentProxy, a as getResolvedPDFJS } from './shared/unpdf.ab6a2535.mjs';
|
|
4
4
|
|
|
5
5
|
const getPDFMeta = async (...args) => {
|
|
6
6
|
await resolvePDFJSImports();
|
package/dist/index.worker.cjs
CHANGED
package/dist/index.worker.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.cjs';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.cjs';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.worker.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.mjs';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.mjs';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.worker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.
|
|
2
|
-
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
import { g as getPDFMeta$1, e as extractPDFText$1, a as getImagesFromPage$1 } from './shared/unpdf.6363738c.js';
|
|
2
|
+
export { d as defineUnPDFConfig, b as getDocumentProxy, c as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.6363738c.js';
|
|
3
3
|
import 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
import 'pdfjs-dist';
|
|
5
5
|
|
package/dist/index.worker.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as defineUnPDFConfig, g as getDocumentProxy, a as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.
|
|
1
|
+
export { d as defineUnPDFConfig, g as getDocumentProxy, a as getResolvedPDFJS, r as resolvePDFJSImports } from './shared/unpdf.ab6a2535.mjs';
|
|
2
2
|
|
|
3
3
|
const getPDFMeta = async () => {
|
|
4
4
|
throw new Error("Not implemented in worker context yet");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as isPDFDocumentProxy, g as getDocumentProxy, a as getResolvedPDFJS } from './unpdf.
|
|
1
|
+
import { i as isPDFDocumentProxy, g as getDocumentProxy, a as getResolvedPDFJS } from './unpdf.ab6a2535.mjs';
|
|
2
2
|
|
|
3
3
|
async function getPDFMeta(data) {
|
|
4
4
|
const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
|
|
@@ -9,7 +9,8 @@ async function getPDFMeta(data) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async function extractPDFText(data,
|
|
12
|
+
async function extractPDFText(data, options = {}) {
|
|
13
|
+
const { mergePages = false } = { ...options };
|
|
13
14
|
const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
|
|
14
15
|
const texts = await Promise.all(
|
|
15
16
|
Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1))
|
|
@@ -12,15 +12,10 @@ async function getDocumentProxy(data, options = {}) {
|
|
|
12
12
|
}).promise;
|
|
13
13
|
return pdf;
|
|
14
14
|
}
|
|
15
|
-
async function defineUnPDFConfig(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
resolvedModule = mod;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
throw new Error("Resolving the PDF.js module failed. Please check your configuration.");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
15
|
+
async function defineUnPDFConfig(options) {
|
|
16
|
+
const { pdfjs } = { ...options };
|
|
17
|
+
if (pdfjs)
|
|
18
|
+
await resolvePDFJSImports(pdfjs);
|
|
24
19
|
}
|
|
25
20
|
async function getResolvedPDFJS() {
|
|
26
21
|
if (!resolvedModule)
|
|
@@ -34,8 +29,9 @@ async function resolvePDFJSImports(pdfjs) {
|
|
|
34
29
|
try {
|
|
35
30
|
const { default: mod } = await pdfjs();
|
|
36
31
|
resolvedModule = mod;
|
|
32
|
+
return;
|
|
37
33
|
} catch (error) {
|
|
38
|
-
throw new Error("Resolving
|
|
34
|
+
throw new Error("Resolving PDF.js failed. Please check the provided configuration.");
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
37
|
try {
|
|
@@ -6,7 +6,7 @@ declare function getPDFMeta(data: BinaryData | PDFDocumentProxy): Promise<{
|
|
|
6
6
|
metadata: Record<string, any>;
|
|
7
7
|
}>;
|
|
8
8
|
|
|
9
|
-
declare function extractPDFText(data: BinaryData | PDFDocumentProxy,
|
|
9
|
+
declare function extractPDFText(data: BinaryData | PDFDocumentProxy, options?: {
|
|
10
10
|
mergePages?: boolean;
|
|
11
11
|
}): Promise<{
|
|
12
12
|
totalPages: number;
|
|
@@ -36,7 +36,7 @@ interface UnPDFConfiguration {
|
|
|
36
36
|
* - `useSystemFonts: true`
|
|
37
37
|
*/
|
|
38
38
|
declare function getDocumentProxy(data: BinaryData, options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
39
|
-
declare function defineUnPDFConfig(
|
|
39
|
+
declare function defineUnPDFConfig(options: UnPDFConfiguration): Promise<void>;
|
|
40
40
|
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
41
41
|
declare function resolvePDFJSImports(pdfjs?: () => Promise<typeof PDFJS>): Promise<void>;
|
|
42
42
|
|
|
@@ -6,7 +6,7 @@ declare function getPDFMeta(data: BinaryData | PDFDocumentProxy): Promise<{
|
|
|
6
6
|
metadata: Record<string, any>;
|
|
7
7
|
}>;
|
|
8
8
|
|
|
9
|
-
declare function extractPDFText(data: BinaryData | PDFDocumentProxy,
|
|
9
|
+
declare function extractPDFText(data: BinaryData | PDFDocumentProxy, options?: {
|
|
10
10
|
mergePages?: boolean;
|
|
11
11
|
}): Promise<{
|
|
12
12
|
totalPages: number;
|
|
@@ -36,7 +36,7 @@ interface UnPDFConfiguration {
|
|
|
36
36
|
* - `useSystemFonts: true`
|
|
37
37
|
*/
|
|
38
38
|
declare function getDocumentProxy(data: BinaryData, options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
39
|
-
declare function defineUnPDFConfig(
|
|
39
|
+
declare function defineUnPDFConfig(options: UnPDFConfiguration): Promise<void>;
|
|
40
40
|
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
41
41
|
declare function resolvePDFJSImports(pdfjs?: () => Promise<typeof PDFJS>): Promise<void>;
|
|
42
42
|
|
|
@@ -6,7 +6,7 @@ declare function getPDFMeta(data: BinaryData | PDFDocumentProxy): Promise<{
|
|
|
6
6
|
metadata: Record<string, any>;
|
|
7
7
|
}>;
|
|
8
8
|
|
|
9
|
-
declare function extractPDFText(data: BinaryData | PDFDocumentProxy,
|
|
9
|
+
declare function extractPDFText(data: BinaryData | PDFDocumentProxy, options?: {
|
|
10
10
|
mergePages?: boolean;
|
|
11
11
|
}): Promise<{
|
|
12
12
|
totalPages: number;
|
|
@@ -36,7 +36,7 @@ interface UnPDFConfiguration {
|
|
|
36
36
|
* - `useSystemFonts: true`
|
|
37
37
|
*/
|
|
38
38
|
declare function getDocumentProxy(data: BinaryData, options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
39
|
-
declare function defineUnPDFConfig(
|
|
39
|
+
declare function defineUnPDFConfig(options: UnPDFConfiguration): Promise<void>;
|
|
40
40
|
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
41
41
|
declare function resolvePDFJSImports(pdfjs?: () => Promise<typeof PDFJS>): Promise<void>;
|
|
42
42
|
|
|
@@ -10,15 +10,10 @@ async function getDocumentProxy(data, options = {}) {
|
|
|
10
10
|
}).promise;
|
|
11
11
|
return pdf;
|
|
12
12
|
}
|
|
13
|
-
async function defineUnPDFConfig(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
resolvedModule = mod;
|
|
18
|
-
} catch (error) {
|
|
19
|
-
throw new Error("Resolving the PDF.js module failed. Please check your configuration.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
13
|
+
async function defineUnPDFConfig(options) {
|
|
14
|
+
const { pdfjs } = { ...options };
|
|
15
|
+
if (pdfjs)
|
|
16
|
+
await resolvePDFJSImports(pdfjs);
|
|
22
17
|
}
|
|
23
18
|
async function getResolvedPDFJS() {
|
|
24
19
|
if (!resolvedModule)
|
|
@@ -32,8 +27,9 @@ async function resolvePDFJSImports(pdfjs) {
|
|
|
32
27
|
try {
|
|
33
28
|
const { default: mod } = await pdfjs();
|
|
34
29
|
resolvedModule = mod;
|
|
30
|
+
return;
|
|
35
31
|
} catch (error) {
|
|
36
|
-
throw new Error("Resolving
|
|
32
|
+
throw new Error("Resolving PDF.js failed. Please check the provided configuration.");
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const utils = require('./unpdf.
|
|
3
|
+
const utils = require('./unpdf.42987ff1.cjs');
|
|
4
4
|
|
|
5
5
|
async function getPDFMeta(data) {
|
|
6
6
|
const pdf = utils.isPDFDocumentProxy(data) ? data : await utils.getDocumentProxy(data);
|
|
@@ -11,7 +11,8 @@ async function getPDFMeta(data) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async function extractPDFText(data,
|
|
14
|
+
async function extractPDFText(data, options = {}) {
|
|
15
|
+
const { mergePages = false } = { ...options };
|
|
15
16
|
const pdf = utils.isPDFDocumentProxy(data) ? data : await utils.getDocumentProxy(data);
|
|
16
17
|
const texts = await Promise.all(
|
|
17
18
|
Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1))
|
package/package.json
CHANGED