@d0paminedriven/pdfdown 0.2.0 → 0.4.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 +98 -41
- package/index.d.ts +21 -1
- package/index.js +54 -51
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -16,11 +16,27 @@ pnpm add @d0paminedriven/pdfdown
|
|
|
16
16
|
|
|
17
17
|
## API
|
|
18
18
|
|
|
19
|
+
### Synchronous
|
|
20
|
+
|
|
19
21
|
```typescript
|
|
20
22
|
export declare function extractTextPerPage(buffer: Buffer): Array<PageText>
|
|
21
23
|
export declare function extractImagesPerPage(buffer: Buffer): Array<PageImage>
|
|
22
24
|
export declare function pdfMetadata(buffer: Buffer): PdfMeta
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Async (libuv thread pool)
|
|
28
|
+
|
|
29
|
+
Each sync function has an async counterpart that runs on the libuv thread pool, keeping the main thread free.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
export declare function extractTextPerPageAsync(buffer: Buffer): Promise<Array<PageText>>
|
|
33
|
+
export declare function extractImagesPerPageAsync(buffer: Buffer): Promise<Array<PageImage>>
|
|
34
|
+
export declare function pdfMetadataAsync(buffer: Buffer): Promise<PdfMeta>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Types
|
|
23
38
|
|
|
39
|
+
```typescript
|
|
24
40
|
export interface PageText {
|
|
25
41
|
page: number
|
|
26
42
|
text: string
|
|
@@ -35,6 +51,8 @@ export interface PageImage {
|
|
|
35
51
|
colorSpace: string
|
|
36
52
|
bitsPerComponent: number
|
|
37
53
|
filter: string
|
|
54
|
+
xobjectName: string
|
|
55
|
+
objectId: string
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
export interface PdfMeta {
|
|
@@ -49,94 +67,133 @@ export interface PdfMeta {
|
|
|
49
67
|
### Extract text per page
|
|
50
68
|
|
|
51
69
|
```typescript
|
|
52
|
-
import { readFileSync } from
|
|
53
|
-
import { extractTextPerPage } from
|
|
70
|
+
import { readFileSync } from 'fs'
|
|
71
|
+
import { extractTextPerPage } from '@d0paminedriven/pdfdown'
|
|
54
72
|
|
|
55
|
-
const pdf = readFileSync(
|
|
56
|
-
const pages = extractTextPerPage(pdf)
|
|
73
|
+
const pdf = readFileSync('document.pdf')
|
|
74
|
+
const pages = extractTextPerPage(pdf)
|
|
57
75
|
|
|
58
76
|
for (const { page, text } of pages) {
|
|
59
|
-
console.log(`Page ${page}: ${text.slice(0, 100)}...`)
|
|
77
|
+
console.log(`Page ${page}: ${text.slice(0, 100)}...`)
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Extract text per page (async)
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { readFile } from 'fs/promises'
|
|
85
|
+
import { extractTextPerPageAsync } from '@d0paminedriven/pdfdown'
|
|
86
|
+
|
|
87
|
+
const pdf = await readFile('document.pdf')
|
|
88
|
+
const pages = await extractTextPerPageAsync(pdf)
|
|
89
|
+
|
|
90
|
+
for (const { page, text } of pages) {
|
|
91
|
+
console.log(`Page ${page}: ${text.slice(0, 100)}...`)
|
|
60
92
|
}
|
|
61
93
|
```
|
|
62
94
|
|
|
63
95
|
### Extract images as PNG
|
|
64
96
|
|
|
65
97
|
```typescript
|
|
66
|
-
import { readFileSync } from
|
|
67
|
-
import { extractImagesPerPage } from
|
|
98
|
+
import { readFileSync } from 'fs'
|
|
99
|
+
import { extractImagesPerPage } from '@d0paminedriven/pdfdown'
|
|
68
100
|
|
|
69
|
-
const pdf = readFileSync(
|
|
70
|
-
const images = extractImagesPerPage(pdf)
|
|
101
|
+
const pdf = readFileSync('document.pdf')
|
|
102
|
+
const images = extractImagesPerPage(pdf)
|
|
71
103
|
|
|
72
104
|
for (const img of images) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
105
|
+
const dataUrl = `data:image/png;base64,${img.data.toString('base64')}`
|
|
106
|
+
console.log(`Page ${img.page} image ${img.imageIndex}: ${img.width}x${img.height} ${img.colorSpace}`)
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Extract images as PNG (async)
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { readFile } from 'fs/promises'
|
|
114
|
+
import { extractImagesPerPageAsync } from '@d0paminedriven/pdfdown'
|
|
115
|
+
|
|
116
|
+
const pdf = await readFile('document.pdf')
|
|
117
|
+
const images = await extractImagesPerPageAsync(pdf)
|
|
118
|
+
|
|
119
|
+
for (const img of images) {
|
|
120
|
+
const dataUrl = `data:image/png;base64,${img.data.toString('base64')}`
|
|
121
|
+
console.log(`Page ${img.page} image ${img.imageIndex}: ${img.width}x${img.height} ${img.colorSpace}`)
|
|
76
122
|
}
|
|
77
123
|
```
|
|
78
124
|
|
|
79
125
|
### Get PDF metadata
|
|
80
126
|
|
|
81
127
|
```typescript
|
|
82
|
-
import { readFileSync } from
|
|
83
|
-
import { pdfMetadata } from
|
|
128
|
+
import { readFileSync } from 'fs'
|
|
129
|
+
import { pdfMetadata } from '@d0paminedriven/pdfdown'
|
|
130
|
+
|
|
131
|
+
const pdf = readFileSync('document.pdf')
|
|
132
|
+
const meta = pdfMetadata(pdf)
|
|
133
|
+
|
|
134
|
+
console.log(`v${meta.version}, ${meta.pageCount} pages, linearized: ${meta.isLinearized}`)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Get PDF metadata (async)
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { readFile } from 'fs/promises'
|
|
141
|
+
import { pdfMetadataAsync } from '@d0paminedriven/pdfdown'
|
|
84
142
|
|
|
85
|
-
const pdf =
|
|
86
|
-
const meta =
|
|
143
|
+
const pdf = await readFile('document.pdf')
|
|
144
|
+
const meta = await pdfMetadataAsync(pdf)
|
|
87
145
|
|
|
88
|
-
console.log(`v${meta.version}, ${meta.pageCount} pages, linearized: ${meta.isLinearized}`)
|
|
146
|
+
console.log(`v${meta.version}, ${meta.pageCount} pages, linearized: ${meta.isLinearized}`)
|
|
89
147
|
```
|
|
90
148
|
|
|
91
|
-
### Combined: text + images
|
|
149
|
+
### Combined: text + images for multimodal embeddings
|
|
92
150
|
|
|
93
151
|
```typescript
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
152
|
+
import { readFile } from 'fs/promises'
|
|
153
|
+
import { extractTextPerPageAsync, extractImagesPerPageAsync } from '@d0paminedriven/pdfdown'
|
|
96
154
|
|
|
97
|
-
const pdf =
|
|
155
|
+
const pdf = await readFile('document.pdf')
|
|
98
156
|
|
|
99
|
-
const text =
|
|
100
|
-
const images = extractImagesPerPage(pdf);
|
|
157
|
+
const [text, images] = await Promise.all([extractTextPerPageAsync(pdf), extractImagesPerPageAsync(pdf)])
|
|
101
158
|
|
|
102
159
|
// Group images by page
|
|
103
|
-
const imagesByPage = new Map<number, typeof images>()
|
|
160
|
+
const imagesByPage = new Map<number, typeof images>()
|
|
104
161
|
for (const img of images) {
|
|
105
|
-
const arr = imagesByPage.get(img.page) ?? []
|
|
106
|
-
arr.push(img)
|
|
107
|
-
imagesByPage.set(img.page, arr)
|
|
162
|
+
const arr = imagesByPage.get(img.page) ?? []
|
|
163
|
+
arr.push(img)
|
|
164
|
+
imagesByPage.set(img.page, arr)
|
|
108
165
|
}
|
|
109
166
|
|
|
110
167
|
// Build per-page payloads for multimodal embeddings
|
|
111
168
|
for (const { page, text: pageText } of text) {
|
|
112
|
-
const pageImages = imagesByPage.get(page) ?? []
|
|
169
|
+
const pageImages = imagesByPage.get(page) ?? []
|
|
113
170
|
const payload = {
|
|
114
171
|
page,
|
|
115
172
|
text: pageText,
|
|
116
173
|
images: pageImages.map((img) => ({
|
|
117
|
-
dataUrl: `data:image/png;base64,${img.data.toString(
|
|
174
|
+
dataUrl: `data:image/png;base64,${img.data.toString('base64')}`,
|
|
118
175
|
width: img.width,
|
|
119
176
|
height: img.height,
|
|
120
177
|
})),
|
|
121
|
-
}
|
|
178
|
+
}
|
|
122
179
|
// Send payload to Voyage AI, pgvector, etc.
|
|
123
180
|
}
|
|
124
181
|
```
|
|
125
182
|
|
|
126
183
|
## Supported formats
|
|
127
184
|
|
|
128
|
-
| Filter
|
|
129
|
-
|
|
130
|
-
| DCTDecode
|
|
185
|
+
| Filter | Description | Handling |
|
|
186
|
+
| ----------- | -------------------------- | ---------------------------------- |
|
|
187
|
+
| DCTDecode | JPEG-compressed images | Decoded and re-encoded as PNG |
|
|
131
188
|
| FlateDecode | Zlib-compressed raw pixels | Decompressed, reconstructed as PNG |
|
|
132
|
-
| None
|
|
133
|
-
|
|
134
|
-
| ColorSpace | Channels
|
|
135
|
-
|
|
136
|
-
| DeviceRGB
|
|
137
|
-
| DeviceGray | 1
|
|
138
|
-
| DeviceCMYK | 4 (converted to RGB)
|
|
139
|
-
| ICCBased
|
|
189
|
+
| None | Uncompressed raw pixels | Reconstructed as PNG |
|
|
190
|
+
|
|
191
|
+
| ColorSpace | Channels |
|
|
192
|
+
| ---------- | -------------------------- |
|
|
193
|
+
| DeviceRGB | 3 |
|
|
194
|
+
| DeviceGray | 1 |
|
|
195
|
+
| DeviceCMYK | 4 (converted to RGB) |
|
|
196
|
+
| ICCBased | Inferred from /N parameter |
|
|
140
197
|
|
|
141
198
|
8-bit and 16-bit BitsPerComponent are both supported (16-bit downscaled to 8-bit for PNG output).
|
|
142
199
|
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export declare class PdfDown {
|
|
4
|
+
constructor(buffer: Buffer)
|
|
5
|
+
/** Sync: extract text per page (reuses the already-parsed document) */
|
|
6
|
+
textPerPage(): Array<PageText>
|
|
7
|
+
/** Sync: extract images per page (reuses the already-parsed document) */
|
|
8
|
+
imagesPerPage(): Array<PageImage>
|
|
9
|
+
/** Sync: get PDF metadata (reuses the already-parsed document) */
|
|
10
|
+
metadata(): PdfMeta
|
|
11
|
+
/** Async: extract text per page on the libuv thread pool */
|
|
12
|
+
textPerPageAsync(): Promise<Array<PageText>>
|
|
13
|
+
/** Async: extract images per page on the libuv thread pool */
|
|
14
|
+
imagesPerPageAsync(): Promise<Array<PageImage>>
|
|
15
|
+
/** Async: get PDF metadata on the libuv thread pool */
|
|
16
|
+
metadataAsync(): Promise<PdfMeta>
|
|
17
|
+
}
|
|
18
|
+
|
|
3
19
|
export declare function extractImagesPerPage(buffer: Buffer): Array<PageImage>
|
|
4
20
|
|
|
21
|
+
export declare function extractImagesPerPageAsync(buffer: Buffer): Promise<Array<PageImage>>
|
|
22
|
+
|
|
5
23
|
export declare function extractTextPerPage(buffer: Buffer): Array<PageText>
|
|
6
24
|
|
|
25
|
+
export declare function extractTextPerPageAsync(buffer: Buffer): Promise<Array<PageText>>
|
|
26
|
+
|
|
7
27
|
export interface PageImage {
|
|
8
28
|
page: number
|
|
9
29
|
imageIndex: number
|
|
@@ -30,4 +50,4 @@ export interface PdfMeta {
|
|
|
30
50
|
|
|
31
51
|
export declare function pdfMetadata(buffer: Buffer): PdfMeta
|
|
32
52
|
|
|
33
|
-
export declare function
|
|
53
|
+
export declare function pdfMetadataAsync(buffer: Buffer): Promise<PdfMeta>
|
package/index.js
CHANGED
|
@@ -80,8 +80,8 @@ function requireNative() {
|
|
|
80
80
|
try {
|
|
81
81
|
const binding = require('@d0paminedriven/pdfdown-android-arm64')
|
|
82
82
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-android-arm64/package.json').version
|
|
83
|
-
if (bindingPackageVersion !== '0.
|
|
84
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
83
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
84
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
85
85
|
}
|
|
86
86
|
return binding
|
|
87
87
|
} catch (e) {
|
|
@@ -96,8 +96,8 @@ function requireNative() {
|
|
|
96
96
|
try {
|
|
97
97
|
const binding = require('@d0paminedriven/pdfdown-android-arm-eabi')
|
|
98
98
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-android-arm-eabi/package.json').version
|
|
99
|
-
if (bindingPackageVersion !== '0.
|
|
100
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
99
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
100
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
101
|
}
|
|
102
102
|
return binding
|
|
103
103
|
} catch (e) {
|
|
@@ -116,8 +116,8 @@ function requireNative() {
|
|
|
116
116
|
try {
|
|
117
117
|
const binding = require('@d0paminedriven/pdfdown-win32-x64-msvc')
|
|
118
118
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-win32-x64-msvc/package.json').version
|
|
119
|
-
if (bindingPackageVersion !== '0.
|
|
120
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
119
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
120
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
121
121
|
}
|
|
122
122
|
return binding
|
|
123
123
|
} catch (e) {
|
|
@@ -132,8 +132,8 @@ function requireNative() {
|
|
|
132
132
|
try {
|
|
133
133
|
const binding = require('@d0paminedriven/pdfdown-win32-ia32-msvc')
|
|
134
134
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-win32-ia32-msvc/package.json').version
|
|
135
|
-
if (bindingPackageVersion !== '0.
|
|
136
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
135
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
136
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
137
137
|
}
|
|
138
138
|
return binding
|
|
139
139
|
} catch (e) {
|
|
@@ -148,8 +148,8 @@ function requireNative() {
|
|
|
148
148
|
try {
|
|
149
149
|
const binding = require('@d0paminedriven/pdfdown-win32-arm64-msvc')
|
|
150
150
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-win32-arm64-msvc/package.json').version
|
|
151
|
-
if (bindingPackageVersion !== '0.
|
|
152
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
151
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
152
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
153
153
|
}
|
|
154
154
|
return binding
|
|
155
155
|
} catch (e) {
|
|
@@ -167,8 +167,8 @@ function requireNative() {
|
|
|
167
167
|
try {
|
|
168
168
|
const binding = require('@d0paminedriven/pdfdown-darwin-universal')
|
|
169
169
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-darwin-universal/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '0.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
170
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
172
|
}
|
|
173
173
|
return binding
|
|
174
174
|
} catch (e) {
|
|
@@ -183,8 +183,8 @@ function requireNative() {
|
|
|
183
183
|
try {
|
|
184
184
|
const binding = require('@d0paminedriven/pdfdown-darwin-x64')
|
|
185
185
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-darwin-x64/package.json').version
|
|
186
|
-
if (bindingPackageVersion !== '0.
|
|
187
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
186
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
188
|
}
|
|
189
189
|
return binding
|
|
190
190
|
} catch (e) {
|
|
@@ -199,8 +199,8 @@ function requireNative() {
|
|
|
199
199
|
try {
|
|
200
200
|
const binding = require('@d0paminedriven/pdfdown-darwin-arm64')
|
|
201
201
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-darwin-arm64/package.json').version
|
|
202
|
-
if (bindingPackageVersion !== '0.
|
|
203
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
202
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
204
|
}
|
|
205
205
|
return binding
|
|
206
206
|
} catch (e) {
|
|
@@ -219,8 +219,8 @@ function requireNative() {
|
|
|
219
219
|
try {
|
|
220
220
|
const binding = require('@d0paminedriven/pdfdown-freebsd-x64')
|
|
221
221
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-freebsd-x64/package.json').version
|
|
222
|
-
if (bindingPackageVersion !== '0.
|
|
223
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
222
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
224
|
}
|
|
225
225
|
return binding
|
|
226
226
|
} catch (e) {
|
|
@@ -235,8 +235,8 @@ function requireNative() {
|
|
|
235
235
|
try {
|
|
236
236
|
const binding = require('@d0paminedriven/pdfdown-freebsd-arm64')
|
|
237
237
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-freebsd-arm64/package.json').version
|
|
238
|
-
if (bindingPackageVersion !== '0.
|
|
239
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
238
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
239
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
240
240
|
}
|
|
241
241
|
return binding
|
|
242
242
|
} catch (e) {
|
|
@@ -256,8 +256,8 @@ function requireNative() {
|
|
|
256
256
|
try {
|
|
257
257
|
const binding = require('@d0paminedriven/pdfdown-linux-x64-musl')
|
|
258
258
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-x64-musl/package.json').version
|
|
259
|
-
if (bindingPackageVersion !== '0.
|
|
260
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
259
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
260
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
261
261
|
}
|
|
262
262
|
return binding
|
|
263
263
|
} catch (e) {
|
|
@@ -272,8 +272,8 @@ function requireNative() {
|
|
|
272
272
|
try {
|
|
273
273
|
const binding = require('@d0paminedriven/pdfdown-linux-x64-gnu')
|
|
274
274
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-x64-gnu/package.json').version
|
|
275
|
-
if (bindingPackageVersion !== '0.
|
|
276
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
275
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
276
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
277
277
|
}
|
|
278
278
|
return binding
|
|
279
279
|
} catch (e) {
|
|
@@ -290,8 +290,8 @@ function requireNative() {
|
|
|
290
290
|
try {
|
|
291
291
|
const binding = require('@d0paminedriven/pdfdown-linux-arm64-musl')
|
|
292
292
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm64-musl/package.json').version
|
|
293
|
-
if (bindingPackageVersion !== '0.
|
|
294
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
293
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
294
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
295
295
|
}
|
|
296
296
|
return binding
|
|
297
297
|
} catch (e) {
|
|
@@ -306,8 +306,8 @@ function requireNative() {
|
|
|
306
306
|
try {
|
|
307
307
|
const binding = require('@d0paminedriven/pdfdown-linux-arm64-gnu')
|
|
308
308
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm64-gnu/package.json').version
|
|
309
|
-
if (bindingPackageVersion !== '0.
|
|
310
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
309
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
311
311
|
}
|
|
312
312
|
return binding
|
|
313
313
|
} catch (e) {
|
|
@@ -324,8 +324,8 @@ function requireNative() {
|
|
|
324
324
|
try {
|
|
325
325
|
const binding = require('@d0paminedriven/pdfdown-linux-arm-musleabihf')
|
|
326
326
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm-musleabihf/package.json').version
|
|
327
|
-
if (bindingPackageVersion !== '0.
|
|
328
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
327
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
328
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
329
329
|
}
|
|
330
330
|
return binding
|
|
331
331
|
} catch (e) {
|
|
@@ -340,8 +340,8 @@ function requireNative() {
|
|
|
340
340
|
try {
|
|
341
341
|
const binding = require('@d0paminedriven/pdfdown-linux-arm-gnueabihf')
|
|
342
342
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm-gnueabihf/package.json').version
|
|
343
|
-
if (bindingPackageVersion !== '0.
|
|
344
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
343
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
344
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
345
345
|
}
|
|
346
346
|
return binding
|
|
347
347
|
} catch (e) {
|
|
@@ -358,8 +358,8 @@ function requireNative() {
|
|
|
358
358
|
try {
|
|
359
359
|
const binding = require('@d0paminedriven/pdfdown-linux-loong64-musl')
|
|
360
360
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-loong64-musl/package.json').version
|
|
361
|
-
if (bindingPackageVersion !== '0.
|
|
362
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
361
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
362
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
363
363
|
}
|
|
364
364
|
return binding
|
|
365
365
|
} catch (e) {
|
|
@@ -374,8 +374,8 @@ function requireNative() {
|
|
|
374
374
|
try {
|
|
375
375
|
const binding = require('@d0paminedriven/pdfdown-linux-loong64-gnu')
|
|
376
376
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-loong64-gnu/package.json').version
|
|
377
|
-
if (bindingPackageVersion !== '0.
|
|
378
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
377
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
378
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
379
379
|
}
|
|
380
380
|
return binding
|
|
381
381
|
} catch (e) {
|
|
@@ -392,8 +392,8 @@ function requireNative() {
|
|
|
392
392
|
try {
|
|
393
393
|
const binding = require('@d0paminedriven/pdfdown-linux-riscv64-musl')
|
|
394
394
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-riscv64-musl/package.json').version
|
|
395
|
-
if (bindingPackageVersion !== '0.
|
|
396
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
395
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
396
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
397
397
|
}
|
|
398
398
|
return binding
|
|
399
399
|
} catch (e) {
|
|
@@ -408,8 +408,8 @@ function requireNative() {
|
|
|
408
408
|
try {
|
|
409
409
|
const binding = require('@d0paminedriven/pdfdown-linux-riscv64-gnu')
|
|
410
410
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-riscv64-gnu/package.json').version
|
|
411
|
-
if (bindingPackageVersion !== '0.
|
|
412
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
411
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
412
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
413
413
|
}
|
|
414
414
|
return binding
|
|
415
415
|
} catch (e) {
|
|
@@ -425,8 +425,8 @@ function requireNative() {
|
|
|
425
425
|
try {
|
|
426
426
|
const binding = require('@d0paminedriven/pdfdown-linux-ppc64-gnu')
|
|
427
427
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-ppc64-gnu/package.json').version
|
|
428
|
-
if (bindingPackageVersion !== '0.
|
|
429
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
428
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
429
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
430
430
|
}
|
|
431
431
|
return binding
|
|
432
432
|
} catch (e) {
|
|
@@ -441,8 +441,8 @@ function requireNative() {
|
|
|
441
441
|
try {
|
|
442
442
|
const binding = require('@d0paminedriven/pdfdown-linux-s390x-gnu')
|
|
443
443
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-s390x-gnu/package.json').version
|
|
444
|
-
if (bindingPackageVersion !== '0.
|
|
445
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
444
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
445
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
446
446
|
}
|
|
447
447
|
return binding
|
|
448
448
|
} catch (e) {
|
|
@@ -461,8 +461,8 @@ function requireNative() {
|
|
|
461
461
|
try {
|
|
462
462
|
const binding = require('@d0paminedriven/pdfdown-openharmony-arm64')
|
|
463
463
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-openharmony-arm64/package.json').version
|
|
464
|
-
if (bindingPackageVersion !== '0.
|
|
465
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
464
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
465
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
466
466
|
}
|
|
467
467
|
return binding
|
|
468
468
|
} catch (e) {
|
|
@@ -477,8 +477,8 @@ function requireNative() {
|
|
|
477
477
|
try {
|
|
478
478
|
const binding = require('@d0paminedriven/pdfdown-openharmony-x64')
|
|
479
479
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-openharmony-x64/package.json').version
|
|
480
|
-
if (bindingPackageVersion !== '0.
|
|
481
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
480
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
481
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
482
482
|
}
|
|
483
483
|
return binding
|
|
484
484
|
} catch (e) {
|
|
@@ -493,8 +493,8 @@ function requireNative() {
|
|
|
493
493
|
try {
|
|
494
494
|
const binding = require('@d0paminedriven/pdfdown-openharmony-arm')
|
|
495
495
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-openharmony-arm/package.json').version
|
|
496
|
-
if (bindingPackageVersion !== '0.
|
|
497
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
496
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
497
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
498
498
|
}
|
|
499
499
|
return binding
|
|
500
500
|
} catch (e) {
|
|
@@ -557,7 +557,10 @@ if (!nativeBinding) {
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
module.exports = nativeBinding
|
|
560
|
+
module.exports.PdfDown = nativeBinding.PdfDown
|
|
560
561
|
module.exports.extractImagesPerPage = nativeBinding.extractImagesPerPage
|
|
562
|
+
module.exports.extractImagesPerPageAsync = nativeBinding.extractImagesPerPageAsync
|
|
561
563
|
module.exports.extractTextPerPage = nativeBinding.extractTextPerPage
|
|
564
|
+
module.exports.extractTextPerPageAsync = nativeBinding.extractTextPerPageAsync
|
|
562
565
|
module.exports.pdfMetadata = nativeBinding.pdfMetadata
|
|
563
|
-
module.exports.
|
|
566
|
+
module.exports.pdfMetadataAsync = nativeBinding.pdfMetadataAsync
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d0paminedriven/pdfdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Rust powered PDF extraction for Node",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@oxc-node/core": "^0.0.35",
|
|
72
72
|
"@taplo/cli": "^0.7.0",
|
|
73
73
|
"@tybys/wasm-util": "^0.10.0",
|
|
74
|
+
"@types/node": "^25.2.0",
|
|
74
75
|
"ava": "^6.4.1",
|
|
75
76
|
"chalk": "^5.6.2",
|
|
76
77
|
"husky": "^9.1.7",
|
|
@@ -115,19 +116,19 @@
|
|
|
115
116
|
},
|
|
116
117
|
"packageManager": "yarn@4.12.0",
|
|
117
118
|
"optionalDependencies": {
|
|
118
|
-
"@d0paminedriven/pdfdown-win32-x64-msvc": "0.
|
|
119
|
-
"@d0paminedriven/pdfdown-darwin-x64": "0.
|
|
120
|
-
"@d0paminedriven/pdfdown-linux-x64-gnu": "0.
|
|
121
|
-
"@d0paminedriven/pdfdown-linux-x64-musl": "0.
|
|
122
|
-
"@d0paminedriven/pdfdown-linux-arm64-gnu": "0.
|
|
123
|
-
"@d0paminedriven/pdfdown-win32-ia32-msvc": "0.
|
|
124
|
-
"@d0paminedriven/pdfdown-linux-arm-gnueabihf": "0.
|
|
125
|
-
"@d0paminedriven/pdfdown-darwin-arm64": "0.
|
|
126
|
-
"@d0paminedriven/pdfdown-android-arm64": "0.
|
|
127
|
-
"@d0paminedriven/pdfdown-freebsd-x64": "0.
|
|
128
|
-
"@d0paminedriven/pdfdown-linux-arm64-musl": "0.
|
|
129
|
-
"@d0paminedriven/pdfdown-win32-arm64-msvc": "0.
|
|
130
|
-
"@d0paminedriven/pdfdown-android-arm-eabi": "0.
|
|
131
|
-
"@d0paminedriven/pdfdown-wasm32-wasi": "0.
|
|
119
|
+
"@d0paminedriven/pdfdown-win32-x64-msvc": "0.4.0",
|
|
120
|
+
"@d0paminedriven/pdfdown-darwin-x64": "0.4.0",
|
|
121
|
+
"@d0paminedriven/pdfdown-linux-x64-gnu": "0.4.0",
|
|
122
|
+
"@d0paminedriven/pdfdown-linux-x64-musl": "0.4.0",
|
|
123
|
+
"@d0paminedriven/pdfdown-linux-arm64-gnu": "0.4.0",
|
|
124
|
+
"@d0paminedriven/pdfdown-win32-ia32-msvc": "0.4.0",
|
|
125
|
+
"@d0paminedriven/pdfdown-linux-arm-gnueabihf": "0.4.0",
|
|
126
|
+
"@d0paminedriven/pdfdown-darwin-arm64": "0.4.0",
|
|
127
|
+
"@d0paminedriven/pdfdown-android-arm64": "0.4.0",
|
|
128
|
+
"@d0paminedriven/pdfdown-freebsd-x64": "0.4.0",
|
|
129
|
+
"@d0paminedriven/pdfdown-linux-arm64-musl": "0.4.0",
|
|
130
|
+
"@d0paminedriven/pdfdown-win32-arm64-msvc": "0.4.0",
|
|
131
|
+
"@d0paminedriven/pdfdown-android-arm-eabi": "0.4.0",
|
|
132
|
+
"@d0paminedriven/pdfdown-wasm32-wasi": "0.4.0"
|
|
132
133
|
}
|
|
133
134
|
}
|