@ooneex/pdf 1.1.3 → 1.1.5
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.d.ts +1 -1
- package/dist/index.js +25 -24
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -516,6 +516,6 @@ declare class PDF implements IPDF {
|
|
|
516
516
|
}
|
|
517
517
|
import { Exception } from "@ooneex/exception";
|
|
518
518
|
declare class PDFException extends Exception {
|
|
519
|
-
constructor(message: string, data?: Record<string, unknown>);
|
|
519
|
+
constructor(message: string, key: string, data?: Record<string, unknown>);
|
|
520
520
|
}
|
|
521
521
|
export { PDFUpdateMetadataOptionsType, PDFToImagesOptionsType, PDFSplitResultType, PDFSplitOptionsType, PDFRemovePagesResultType, PDFPageImageResultType, PDFOptionsType, PDFMetadataResultType, PDFGetImagesResultType, PDFGetImagesOptionsType, PDFExtractedImageType, PDFException, PDFCreateResultType, PDFCreateOptionsType, PDFAddPageResultType, PDFAddPageOptionsType, PDF, IPDF };
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,9 @@ import { Exception } from "@ooneex/exception";
|
|
|
11
11
|
import { HttpStatus } from "@ooneex/http-status";
|
|
12
12
|
|
|
13
13
|
class PDFException extends Exception {
|
|
14
|
-
constructor(message, data = {}) {
|
|
14
|
+
constructor(message, key, data = {}) {
|
|
15
15
|
super(message, {
|
|
16
|
+
key,
|
|
16
17
|
status: HttpStatus.Code.InternalServerError,
|
|
17
18
|
data
|
|
18
19
|
});
|
|
@@ -61,7 +62,7 @@ class PDF {
|
|
|
61
62
|
if (error instanceof PDFException) {
|
|
62
63
|
throw error;
|
|
63
64
|
}
|
|
64
|
-
throw new PDFException("Failed to create PDF document", {
|
|
65
|
+
throw new PDFException("Failed to create PDF document", "PDF_CREATE_FAILED", {
|
|
65
66
|
source: this.source,
|
|
66
67
|
error: error instanceof Error ? error.message : String(error)
|
|
67
68
|
});
|
|
@@ -106,7 +107,7 @@ class PDF {
|
|
|
106
107
|
if (error instanceof PDFException) {
|
|
107
108
|
throw error;
|
|
108
109
|
}
|
|
109
|
-
throw new PDFException("Failed to add page to PDF", {
|
|
110
|
+
throw new PDFException("Failed to add page to PDF", "PDF_ADD_PAGE_FAILED", {
|
|
110
111
|
source: this.source,
|
|
111
112
|
error: error instanceof Error ? error.message : String(error)
|
|
112
113
|
});
|
|
@@ -134,7 +135,7 @@ class PDF {
|
|
|
134
135
|
if (error instanceof PDFException) {
|
|
135
136
|
throw error;
|
|
136
137
|
}
|
|
137
|
-
throw new PDFException("Failed to get PDF metadata", {
|
|
138
|
+
throw new PDFException("Failed to get PDF metadata", "PDF_METADATA_GET_FAILED", {
|
|
138
139
|
source: this.source,
|
|
139
140
|
error: error instanceof Error ? error.message : String(error)
|
|
140
141
|
});
|
|
@@ -176,7 +177,7 @@ class PDF {
|
|
|
176
177
|
if (error instanceof PDFException) {
|
|
177
178
|
throw error;
|
|
178
179
|
}
|
|
179
|
-
throw new PDFException("Failed to update PDF metadata", {
|
|
180
|
+
throw new PDFException("Failed to update PDF metadata", "PDF_METADATA_UPDATE_FAILED", {
|
|
180
181
|
source: this.source,
|
|
181
182
|
error: error instanceof Error ? error.message : String(error)
|
|
182
183
|
});
|
|
@@ -191,7 +192,7 @@ class PDF {
|
|
|
191
192
|
});
|
|
192
193
|
return pdfDoc.getPageCount();
|
|
193
194
|
} catch (error) {
|
|
194
|
-
throw new PDFException("Failed to get page count", {
|
|
195
|
+
throw new PDFException("Failed to get page count", "PDF_PAGE_COUNT_FAILED", {
|
|
195
196
|
source: this.source,
|
|
196
197
|
error: error instanceof Error ? error.message : String(error)
|
|
197
198
|
});
|
|
@@ -199,7 +200,7 @@ class PDF {
|
|
|
199
200
|
}
|
|
200
201
|
async getPageContent(pageNumber) {
|
|
201
202
|
if (pageNumber < 1 || !Number.isInteger(pageNumber)) {
|
|
202
|
-
throw new PDFException("Page number must be a positive integer", {
|
|
203
|
+
throw new PDFException("Page number must be a positive integer", "PDF_INVALID_PAGE_NUMBER", {
|
|
203
204
|
pageNumber
|
|
204
205
|
});
|
|
205
206
|
}
|
|
@@ -208,7 +209,7 @@ class PDF {
|
|
|
208
209
|
const document = await getDocumentProxy(new Uint8Array(sourceBytes));
|
|
209
210
|
const totalPages = document.numPages;
|
|
210
211
|
if (pageNumber > totalPages) {
|
|
211
|
-
throw new PDFException("Page number exceeds total pages", {
|
|
212
|
+
throw new PDFException("Page number exceeds total pages", "PDF_PAGE_OUT_OF_RANGE", {
|
|
212
213
|
pageNumber,
|
|
213
214
|
totalPages
|
|
214
215
|
});
|
|
@@ -222,7 +223,7 @@ class PDF {
|
|
|
222
223
|
if (error instanceof PDFException) {
|
|
223
224
|
throw error;
|
|
224
225
|
}
|
|
225
|
-
throw new PDFException("Failed to get page content", {
|
|
226
|
+
throw new PDFException("Failed to get page content", "PDF_PAGE_CONTENT_FAILED", {
|
|
226
227
|
source: this.source,
|
|
227
228
|
pageNumber,
|
|
228
229
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -232,7 +233,7 @@ class PDF {
|
|
|
232
233
|
async getImages(options) {
|
|
233
234
|
const { pageNumber } = options;
|
|
234
235
|
if (pageNumber !== undefined && (pageNumber < 1 || !Number.isInteger(pageNumber))) {
|
|
235
|
-
throw new PDFException("Page number must be a positive integer", {
|
|
236
|
+
throw new PDFException("Page number must be a positive integer", "PDF_INVALID_PAGE_NUMBER", {
|
|
236
237
|
pageNumber
|
|
237
238
|
});
|
|
238
239
|
}
|
|
@@ -243,7 +244,7 @@ class PDF {
|
|
|
243
244
|
const document = await getDocumentProxy(new Uint8Array(sourceBytes));
|
|
244
245
|
const totalPages = document.numPages;
|
|
245
246
|
if (pageNumber !== undefined && pageNumber > totalPages) {
|
|
246
|
-
throw new PDFException("Page number exceeds total pages", {
|
|
247
|
+
throw new PDFException("Page number exceeds total pages", "PDF_PAGE_OUT_OF_RANGE", {
|
|
247
248
|
pageNumber,
|
|
248
249
|
totalPages
|
|
249
250
|
});
|
|
@@ -282,7 +283,7 @@ class PDF {
|
|
|
282
283
|
if (error instanceof PDFException) {
|
|
283
284
|
throw error;
|
|
284
285
|
}
|
|
285
|
-
throw new PDFException("Failed to extract images from PDF", {
|
|
286
|
+
throw new PDFException("Failed to extract images from PDF", "PDF_EXTRACT_IMAGES_FAILED", {
|
|
286
287
|
source: this.source,
|
|
287
288
|
outputDir: normalizedOutputDir,
|
|
288
289
|
pageNumber,
|
|
@@ -311,7 +312,7 @@ class PDF {
|
|
|
311
312
|
globalThis.pdfjsWorker = savedWorker;
|
|
312
313
|
} catch (error) {
|
|
313
314
|
globalThis.pdfjsWorker = savedWorker;
|
|
314
|
-
throw new PDFException("Failed to convert PDF to images", {
|
|
315
|
+
throw new PDFException("Failed to convert PDF to images", "PDF_CONVERT_IMAGES_FAILED", {
|
|
315
316
|
source: this.source,
|
|
316
317
|
outputDir: normalizedOutputDir,
|
|
317
318
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -320,7 +321,7 @@ class PDF {
|
|
|
320
321
|
}
|
|
321
322
|
async pageToImage(pageNumber, options) {
|
|
322
323
|
if (pageNumber < 1 || !Number.isInteger(pageNumber)) {
|
|
323
|
-
throw new PDFException("Page number must be a positive integer", {
|
|
324
|
+
throw new PDFException("Page number must be a positive integer", "PDF_INVALID_PAGE_NUMBER", {
|
|
324
325
|
pageNumber
|
|
325
326
|
});
|
|
326
327
|
}
|
|
@@ -331,7 +332,7 @@ class PDF {
|
|
|
331
332
|
try {
|
|
332
333
|
const document = await pdf(this.source, this.options);
|
|
333
334
|
if (pageNumber > document.length) {
|
|
334
|
-
throw new PDFException("Page number exceeds total pages", {
|
|
335
|
+
throw new PDFException("Page number exceeds total pages", "PDF_PAGE_OUT_OF_RANGE", {
|
|
335
336
|
pageNumber,
|
|
336
337
|
totalPages: document.length
|
|
337
338
|
});
|
|
@@ -350,7 +351,7 @@ class PDF {
|
|
|
350
351
|
if (error instanceof PDFException) {
|
|
351
352
|
throw error;
|
|
352
353
|
}
|
|
353
|
-
throw new PDFException("Failed to get page image", {
|
|
354
|
+
throw new PDFException("Failed to get page image", "PDF_PAGE_IMAGE_FAILED", {
|
|
354
355
|
source: this.source,
|
|
355
356
|
pageNumber,
|
|
356
357
|
outputDir: normalizedOutputDir,
|
|
@@ -368,14 +369,14 @@ class PDF {
|
|
|
368
369
|
});
|
|
369
370
|
const totalPages = sourcePdf.getPageCount();
|
|
370
371
|
if (totalPages === 0) {
|
|
371
|
-
throw new PDFException("PDF has no pages", {
|
|
372
|
+
throw new PDFException("PDF has no pages", "PDF_NO_PAGES", {
|
|
372
373
|
source: this.source
|
|
373
374
|
});
|
|
374
375
|
}
|
|
375
376
|
const ranges = this.normalizeRanges(options.ranges, totalPages);
|
|
376
377
|
for (const { start, end } of ranges) {
|
|
377
378
|
if (start < 1 || end > totalPages || start > end) {
|
|
378
|
-
throw new PDFException("Invalid page range", {
|
|
379
|
+
throw new PDFException("Invalid page range", "PDF_INVALID_PAGE_RANGE", {
|
|
379
380
|
start,
|
|
380
381
|
end,
|
|
381
382
|
totalPages
|
|
@@ -402,7 +403,7 @@ class PDF {
|
|
|
402
403
|
if (error instanceof PDFException) {
|
|
403
404
|
throw error;
|
|
404
405
|
}
|
|
405
|
-
throw new PDFException("Failed to split PDF", {
|
|
406
|
+
throw new PDFException("Failed to split PDF", "PDF_SPLIT_FAILED", {
|
|
406
407
|
source: this.source,
|
|
407
408
|
outputDir: normalizedOutputDir,
|
|
408
409
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -417,18 +418,18 @@ class PDF {
|
|
|
417
418
|
});
|
|
418
419
|
const totalPages = pdfDoc.getPageCount();
|
|
419
420
|
if (totalPages === 0) {
|
|
420
|
-
throw new PDFException("PDF has no pages", {
|
|
421
|
+
throw new PDFException("PDF has no pages", "PDF_NO_PAGES", {
|
|
421
422
|
source: this.source
|
|
422
423
|
});
|
|
423
424
|
}
|
|
424
425
|
const pagesToRemove = this.normalizePageNumbers(pages, totalPages);
|
|
425
426
|
if (pagesToRemove.length === 0) {
|
|
426
|
-
throw new PDFException("No valid pages specified for removal", {
|
|
427
|
+
throw new PDFException("No valid pages specified for removal", "PDF_NO_VALID_PAGES", {
|
|
427
428
|
pages
|
|
428
429
|
});
|
|
429
430
|
}
|
|
430
431
|
if (pagesToRemove.length >= totalPages) {
|
|
431
|
-
throw new PDFException("Cannot remove all pages from PDF", {
|
|
432
|
+
throw new PDFException("Cannot remove all pages from PDF", "PDF_CANNOT_REMOVE_ALL_PAGES", {
|
|
432
433
|
pagesToRemove,
|
|
433
434
|
totalPages
|
|
434
435
|
});
|
|
@@ -446,7 +447,7 @@ class PDF {
|
|
|
446
447
|
if (error instanceof PDFException) {
|
|
447
448
|
throw error;
|
|
448
449
|
}
|
|
449
|
-
throw new PDFException("Failed to remove pages from PDF", {
|
|
450
|
+
throw new PDFException("Failed to remove pages from PDF", "PDF_REMOVE_PAGES_FAILED", {
|
|
450
451
|
source: this.source,
|
|
451
452
|
pages,
|
|
452
453
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -493,4 +494,4 @@ export {
|
|
|
493
494
|
PDF
|
|
494
495
|
};
|
|
495
496
|
|
|
496
|
-
//# debugId=
|
|
497
|
+
//# debugId=50118D49CA2A880B64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/PDF.ts", "src/PDFException.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import path from \"node:path\";\nimport { PDFDocument, rgb, StandardFonts } from \"pdf-lib\";\nimport { pdf } from \"pdf-to-img\";\nimport sharp from \"sharp\";\nimport { extractImages, getDocumentProxy } from \"unpdf\";\nimport { PDFException } from \"./PDFException\";\nimport type {\n IPDF,\n PDFAddPageOptionsType,\n PDFAddPageResultType,\n PDFCreateOptionsType,\n PDFCreateResultType,\n PDFExtractedImageType,\n PDFGetImagesOptionsType,\n PDFGetImagesResultType,\n PDFMetadataResultType,\n PDFOptionsType,\n PDFPageImageResultType,\n PDFRemovePagesResultType,\n PDFSplitOptionsType,\n PDFSplitResultType,\n PDFToImagesOptionsType,\n PDFUpdateMetadataOptionsType,\n} from \"./types\";\n\nexport class PDF implements IPDF {\n private readonly source: string;\n private readonly options: PDFOptionsType;\n\n /**\n * Create a new PDF instance\n * @param source - Path to PDF file\n * @param options - Options for PDF processing\n */\n constructor(source: string, options: PDFOptionsType = {}) {\n this.source = path.join(...source.split(/[/\\\\]/));\n this.options = {\n scale: options.scale ?? 3,\n ...(options.password !== undefined && { password: options.password }),\n };\n }\n\n /**\n * Create a new PDF document and save to the source path\n * @param options - Optional content and metadata options for the PDF document\n * @returns Result containing the page count\n *\n * @example\n * ```typescript\n * // Create a simple empty PDF\n * const pdf = new PDF(\"/path/to/output.pdf\");\n * const result = await pdf.create();\n *\n * // Create a PDF with metadata\n * const pdf = new PDF(\"/path/to/output.pdf\");\n * const result = await pdf.create({\n * title: \"My Document\",\n * author: \"John Doe\",\n * subject: \"Example PDF\",\n * keywords: [\"example\", \"pdf\", \"document\"],\n * creator: \"My App\",\n * producer: \"pdf-lib\",\n * });\n * ```\n */\n public async create(options: PDFCreateOptionsType = {}): Promise<PDFCreateResultType> {\n try {\n const pdfDoc = await PDFDocument.create();\n\n // Set metadata if provided\n if (options.title) {\n pdfDoc.setTitle(options.title);\n }\n if (options.author) {\n pdfDoc.setAuthor(options.author);\n }\n if (options.subject) {\n pdfDoc.setSubject(options.subject);\n }\n if (options.keywords) {\n pdfDoc.setKeywords(options.keywords);\n }\n if (options.producer) {\n pdfDoc.setProducer(options.producer);\n }\n if (options.creator) {\n pdfDoc.setCreator(options.creator);\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n\n return {\n pageCount: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to create PDF document\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Add a page to an existing PDF document\n * @param options - Optional content options for the page\n * @returns Result containing the total page count\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Add an empty page\n * await pdf.addPage();\n *\n * // Add a page with content\n * await pdf.addPage({\n * content: \"Hello, World!\",\n * fontSize: 24,\n * });\n * ```\n */\n public async addPage(options: PDFAddPageOptionsType = {}): Promise<PDFAddPageResultType> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n const page = pdfDoc.addPage();\n\n // Add content if provided\n if (options.content) {\n const font = await pdfDoc.embedFont(StandardFonts.Helvetica);\n const fontSize = options.fontSize ?? 12;\n const margin = 50;\n const lineHeight = fontSize * 1.2;\n\n const { height } = page.getSize();\n let y = height - margin;\n\n const lines = options.content.split(\"\\n\");\n\n for (const line of lines) {\n if (y < margin) {\n break;\n }\n\n page.drawText(line, {\n x: margin,\n y,\n size: fontSize,\n font,\n color: rgb(0, 0, 0),\n });\n\n y -= lineHeight;\n }\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n\n return {\n pageCount: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to add page to PDF\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Get metadata from the PDF document\n * @returns PDF metadata including title, author, dates, and page count\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n * const metadata = await pdf.getMetadata();\n *\n * console.log(metadata.title);\n * console.log(metadata.author);\n * console.log(metadata.pageCount);\n * ```\n */\n public async getMetadata(): Promise<PDFMetadataResultType> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n updateMetadata: false,\n });\n\n return {\n title: pdfDoc.getTitle(),\n author: pdfDoc.getAuthor(),\n subject: pdfDoc.getSubject(),\n keywords: pdfDoc.getKeywords(),\n producer: pdfDoc.getProducer(),\n creator: pdfDoc.getCreator(),\n creationDate: pdfDoc.getCreationDate(),\n modificationDate: pdfDoc.getModificationDate(),\n pageCount: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to get PDF metadata\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Update metadata of an existing PDF document\n * @param options - Metadata options to update\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n * await pdf.updateMetadata({\n * title: \"Updated Title\",\n * author: \"New Author\",\n * subject: \"Updated Subject\",\n * keywords: [\"updated\", \"keywords\"],\n * producer: \"My App\",\n * creator: \"pdf-lib\",\n * creationDate: new Date(\"2020-01-01\"),\n * modificationDate: new Date(),\n * });\n * ```\n */\n public async updateMetadata(options: PDFUpdateMetadataOptionsType): Promise<void> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n if (options.title !== undefined) {\n pdfDoc.setTitle(options.title);\n }\n if (options.author !== undefined) {\n pdfDoc.setAuthor(options.author);\n }\n if (options.subject !== undefined) {\n pdfDoc.setSubject(options.subject);\n }\n if (options.keywords !== undefined) {\n pdfDoc.setKeywords(options.keywords);\n }\n if (options.producer !== undefined) {\n pdfDoc.setProducer(options.producer);\n }\n if (options.creator !== undefined) {\n pdfDoc.setCreator(options.creator);\n }\n if (options.creationDate !== undefined) {\n pdfDoc.setCreationDate(options.creationDate);\n }\n if (options.modificationDate !== undefined) {\n pdfDoc.setModificationDate(options.modificationDate);\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to update PDF metadata\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Get the total number of pages in the PDF\n */\n public async getPageCount(): Promise<number> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n updateMetadata: false,\n });\n return pdfDoc.getPageCount();\n } catch (error) {\n throw new PDFException(\"Failed to get page count\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Get the text content of a specific page\n * @param pageNumber - Page number (1-indexed)\n * @returns Extracted text content from the page\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Get content from page 1\n * const content = await pdf.getPageContent(1);\n * console.log(content); // \"Lorem ipsum dolor sit amet...\"\n *\n * // Get content from a specific page\n * const page3Content = await pdf.getPageContent(3);\n * console.log(page3Content); // Plain text content\n * ```\n */\n public async getPageContent(pageNumber: number): Promise<string> {\n if (pageNumber < 1 || !Number.isInteger(pageNumber)) {\n throw new PDFException(\"Page number must be a positive integer\", {\n pageNumber,\n });\n }\n\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n const document = await getDocumentProxy(new Uint8Array(sourceBytes));\n const totalPages = document.numPages;\n\n if (pageNumber > totalPages) {\n throw new PDFException(\"Page number exceeds total pages\", {\n pageNumber,\n totalPages,\n });\n }\n\n const page = await document.getPage(pageNumber);\n const textContent = await page.getTextContent();\n const text = textContent.items\n .filter((item) => \"str\" in item)\n .map((item) => (\"hasEOL\" in item && item.hasEOL ? `${item.str}\\n` : item.str))\n .join(\"\");\n\n return text.trim();\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to get page content\", {\n source: this.source,\n pageNumber,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Extract images from PDF pages and save to disk\n * @param options - Options including output directory, optional prefix, and optional page number\n * @returns Result containing total pages and array of extracted images with file paths\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Extract images from all pages\n * const images = await pdf.getImages({ outputDir: \"/output\" });\n * console.log(`Found ${images.length} images`);\n *\n * // Extract images from a specific page\n * const page1Images = await pdf.getImages({ outputDir: \"/output\", prefix: \"doc\", pageNumber: 1 });\n * for (const image of page1Images) {\n * console.log(`Image: ${image.path}, ${image.width}x${image.height}`);\n * }\n * ```\n */\n public async getImages(options: PDFGetImagesOptionsType): Promise<PDFGetImagesResultType> {\n const { pageNumber } = options;\n\n if (pageNumber !== undefined && (pageNumber < 1 || !Number.isInteger(pageNumber))) {\n throw new PDFException(\"Page number must be a positive integer\", {\n pageNumber,\n });\n }\n\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"image\";\n\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n const document = await getDocumentProxy(new Uint8Array(sourceBytes));\n const totalPages = document.numPages;\n\n if (pageNumber !== undefined && pageNumber > totalPages) {\n throw new PDFException(\"Page number exceeds total pages\", {\n pageNumber,\n totalPages,\n });\n }\n\n const processPage = async (page: number) => {\n const pageImages = await extractImages(document, page);\n const results: PDFExtractedImageType[] = [];\n let imageIndex = 0;\n for (const img of pageImages) {\n imageIndex++;\n const fileName = `${prefix}-p${page}-${imageIndex}.png`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n // Convert raw image data to PNG using sharp\n const pngBuffer = await sharp(img.data, {\n raw: {\n width: img.width,\n height: img.height,\n channels: img.channels,\n },\n })\n .png()\n .toBuffer();\n\n await Bun.write(filePath, pngBuffer);\n\n results.push({\n page,\n path: filePath,\n width: img.width,\n height: img.height,\n });\n }\n return results;\n };\n\n if (pageNumber !== undefined) {\n return await processPage(pageNumber);\n }\n\n const allResults = await Promise.all(Array.from({ length: totalPages }, (_, i) => processPage(i + 1)));\n return allResults.flat();\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to extract images from PDF\", {\n source: this.source,\n outputDir: normalizedOutputDir,\n pageNumber,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Convert all pages to images and save to disk\n * @param options - Options including output directory and optional prefix\n * @returns Array of page image results with page numbers and file paths\n */\n public async *pagesToImages(options: PDFToImagesOptionsType): AsyncGenerator<PDFPageImageResultType, void, unknown> {\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"page\";\n const savedWorker = (globalThis as Record<string, unknown>).pdfjsWorker;\n (globalThis as Record<string, unknown>).pdfjsWorker = undefined;\n\n try {\n const document = await pdf(this.source, this.options);\n let pageNumber = 1;\n\n for await (const image of document) {\n const fileName = `${prefix}-${pageNumber}.png`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n await Bun.write(filePath, Buffer.from(image));\n\n yield {\n page: pageNumber,\n path: filePath,\n };\n pageNumber++;\n }\n\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n } catch (error) {\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n throw new PDFException(\"Failed to convert PDF to images\", {\n source: this.source,\n outputDir: normalizedOutputDir,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Convert a specific page to an image and save to disk\n * @param pageNumber - Page number (1-indexed)\n * @param options - Options including output directory and optional prefix\n * @returns Page image result with page number and file path\n */\n public async pageToImage(pageNumber: number, options: PDFToImagesOptionsType): Promise<PDFPageImageResultType> {\n if (pageNumber < 1 || !Number.isInteger(pageNumber)) {\n throw new PDFException(\"Page number must be a positive integer\", {\n pageNumber,\n });\n }\n\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"page\";\n const savedWorker = (globalThis as Record<string, unknown>).pdfjsWorker;\n (globalThis as Record<string, unknown>).pdfjsWorker = undefined;\n\n try {\n const document = await pdf(this.source, this.options);\n\n if (pageNumber > document.length) {\n throw new PDFException(\"Page number exceeds total pages\", {\n pageNumber,\n totalPages: document.length,\n });\n }\n\n const image = await document.getPage(pageNumber);\n\n const fileName = `${prefix}-${pageNumber}.png`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n await Bun.write(filePath, Buffer.from(image));\n\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n\n return {\n page: pageNumber,\n path: filePath,\n };\n } catch (error) {\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to get page image\", {\n source: this.source,\n pageNumber,\n outputDir: normalizedOutputDir,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Split the PDF into separate documents and save to disk\n * @param options - Split options with output directory, page ranges, and optional prefix\n * @returns Array of split PDF results with page ranges and file paths\n */\n public async *split(options: PDFSplitOptionsType): AsyncGenerator<PDFSplitResultType, void, unknown> {\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"page\";\n\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const sourcePdf = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n const totalPages = sourcePdf.getPageCount();\n\n if (totalPages === 0) {\n throw new PDFException(\"PDF has no pages\", {\n source: this.source,\n });\n }\n\n const ranges = this.normalizeRanges(options.ranges, totalPages);\n\n // Validate all ranges first\n for (const { start, end } of ranges) {\n if (start < 1 || end > totalPages || start > end) {\n throw new PDFException(\"Invalid page range\", {\n start,\n end,\n totalPages,\n });\n }\n }\n\n for (const { start, end } of ranges) {\n const newPdf = await PDFDocument.create();\n const pageIndices = Array.from({ length: end - start + 1 }, (_, i) => start - 1 + i);\n const copiedPages = await newPdf.copyPages(sourcePdf, pageIndices);\n\n for (const page of copiedPages) {\n newPdf.addPage(page);\n }\n\n const pdfBytes = await newPdf.save();\n\n const fileName = start === end ? `${prefix}-${start}.pdf` : `${prefix}-${start}-${end}.pdf`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n await Bun.write(filePath, pdfBytes);\n\n yield {\n pages: { start, end },\n path: filePath,\n };\n }\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to split PDF\", {\n source: this.source,\n outputDir: normalizedOutputDir,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Remove specified pages from the PDF\n * @param pages - Page numbers to remove (1-indexed). Can be individual numbers or ranges [start, end]\n * @returns Result with remaining page count and PDF buffer\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Remove individual pages (pages 2 and 5)\n * const result1 = await pdf.removePages([2, 5]);\n *\n * // Remove a range of pages (pages 3 to 6)\n * const result2 = await pdf.removePages([[3, 6]]);\n *\n * // Remove mixed: individual pages and ranges (pages 1, 4-6, and 10)\n * const result3 = await pdf.removePages([1, [4, 6], 10]);\n *\n * console.log(result3.remainingPages); // Number of pages left\n * console.log(result3.buffer); // Buffer containing the resulting PDF\n *\n * // Save to file\n * await Bun.write(\"/path/to/output.pdf\", result3.buffer);\n * ```\n */\n public async removePages(pages: (number | [number, number])[]): Promise<PDFRemovePagesResultType> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n const totalPages = pdfDoc.getPageCount();\n\n if (totalPages === 0) {\n throw new PDFException(\"PDF has no pages\", {\n source: this.source,\n });\n }\n\n // Normalize page numbers to remove into a flat sorted array\n const pagesToRemove = this.normalizePageNumbers(pages, totalPages);\n\n if (pagesToRemove.length === 0) {\n throw new PDFException(\"No valid pages specified for removal\", {\n pages,\n });\n }\n\n if (pagesToRemove.length >= totalPages) {\n throw new PDFException(\"Cannot remove all pages from PDF\", {\n pagesToRemove,\n totalPages,\n });\n }\n\n // Remove pages in reverse order to maintain correct indices\n const sortedDescending = [...pagesToRemove].sort((a, b) => b - a);\n for (const pageNum of sortedDescending) {\n pdfDoc.removePage(pageNum - 1); // Convert to 0-indexed\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n\n return {\n remainingPages: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to remove pages from PDF\", {\n source: this.source,\n pages,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Normalize page numbers into a flat array of unique valid page numbers\n */\n private normalizePageNumbers(pages: (number | [number, number])[], totalPages: number): number[] {\n const pageSet = new Set<number>();\n\n for (const page of pages) {\n if (typeof page === \"number\") {\n if (page >= 1 && page <= totalPages && Number.isInteger(page)) {\n pageSet.add(page);\n }\n } else {\n const [start, end] = page;\n if (start <= end) {\n for (let i = Math.max(1, start); i <= Math.min(totalPages, end); i++) {\n if (Number.isInteger(i)) {\n pageSet.add(i);\n }\n }\n }\n }\n }\n\n return Array.from(pageSet);\n }\n\n /**\n * Normalize page ranges for splitting\n * If no ranges provided, creates individual page ranges\n */\n private normalizeRanges(\n ranges: PDFSplitOptionsType[\"ranges\"] | undefined,\n totalPages: number,\n ): { start: number; end: number }[] {\n if (!ranges || ranges.length === 0) {\n return Array.from({ length: totalPages }, (_, i) => ({\n start: i + 1,\n end: i + 1,\n }));\n }\n\n return ranges.map((range) => {\n if (typeof range === \"number\") {\n return { start: range, end: range };\n }\n return { start: range[0], end: range[1] };\n });\n }\n}\n",
|
|
6
|
-
"import { Exception } from \"@ooneex/exception\";\nimport { HttpStatus } from \"@ooneex/http-status\";\n\nexport class PDFException extends Exception {\n constructor(message: string, data: Record<string, unknown> = {}) {\n super(message, {\n status: HttpStatus.Code.InternalServerError,\n data,\n });\n this.name = \"PDFException\";\n }\n}\n"
|
|
5
|
+
"import path from \"node:path\";\nimport { PDFDocument, rgb, StandardFonts } from \"pdf-lib\";\nimport { pdf } from \"pdf-to-img\";\nimport sharp from \"sharp\";\nimport { extractImages, getDocumentProxy } from \"unpdf\";\nimport { PDFException } from \"./PDFException\";\nimport type {\n IPDF,\n PDFAddPageOptionsType,\n PDFAddPageResultType,\n PDFCreateOptionsType,\n PDFCreateResultType,\n PDFExtractedImageType,\n PDFGetImagesOptionsType,\n PDFGetImagesResultType,\n PDFMetadataResultType,\n PDFOptionsType,\n PDFPageImageResultType,\n PDFRemovePagesResultType,\n PDFSplitOptionsType,\n PDFSplitResultType,\n PDFToImagesOptionsType,\n PDFUpdateMetadataOptionsType,\n} from \"./types\";\n\nexport class PDF implements IPDF {\n private readonly source: string;\n private readonly options: PDFOptionsType;\n\n /**\n * Create a new PDF instance\n * @param source - Path to PDF file\n * @param options - Options for PDF processing\n */\n constructor(source: string, options: PDFOptionsType = {}) {\n this.source = path.join(...source.split(/[/\\\\]/));\n this.options = {\n scale: options.scale ?? 3,\n ...(options.password !== undefined && { password: options.password }),\n };\n }\n\n /**\n * Create a new PDF document and save to the source path\n * @param options - Optional content and metadata options for the PDF document\n * @returns Result containing the page count\n *\n * @example\n * ```typescript\n * // Create a simple empty PDF\n * const pdf = new PDF(\"/path/to/output.pdf\");\n * const result = await pdf.create();\n *\n * // Create a PDF with metadata\n * const pdf = new PDF(\"/path/to/output.pdf\");\n * const result = await pdf.create({\n * title: \"My Document\",\n * author: \"John Doe\",\n * subject: \"Example PDF\",\n * keywords: [\"example\", \"pdf\", \"document\"],\n * creator: \"My App\",\n * producer: \"pdf-lib\",\n * });\n * ```\n */\n public async create(options: PDFCreateOptionsType = {}): Promise<PDFCreateResultType> {\n try {\n const pdfDoc = await PDFDocument.create();\n\n // Set metadata if provided\n if (options.title) {\n pdfDoc.setTitle(options.title);\n }\n if (options.author) {\n pdfDoc.setAuthor(options.author);\n }\n if (options.subject) {\n pdfDoc.setSubject(options.subject);\n }\n if (options.keywords) {\n pdfDoc.setKeywords(options.keywords);\n }\n if (options.producer) {\n pdfDoc.setProducer(options.producer);\n }\n if (options.creator) {\n pdfDoc.setCreator(options.creator);\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n\n return {\n pageCount: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to create PDF document\", \"PDF_CREATE_FAILED\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Add a page to an existing PDF document\n * @param options - Optional content options for the page\n * @returns Result containing the total page count\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Add an empty page\n * await pdf.addPage();\n *\n * // Add a page with content\n * await pdf.addPage({\n * content: \"Hello, World!\",\n * fontSize: 24,\n * });\n * ```\n */\n public async addPage(options: PDFAddPageOptionsType = {}): Promise<PDFAddPageResultType> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n const page = pdfDoc.addPage();\n\n // Add content if provided\n if (options.content) {\n const font = await pdfDoc.embedFont(StandardFonts.Helvetica);\n const fontSize = options.fontSize ?? 12;\n const margin = 50;\n const lineHeight = fontSize * 1.2;\n\n const { height } = page.getSize();\n let y = height - margin;\n\n const lines = options.content.split(\"\\n\");\n\n for (const line of lines) {\n if (y < margin) {\n break;\n }\n\n page.drawText(line, {\n x: margin,\n y,\n size: fontSize,\n font,\n color: rgb(0, 0, 0),\n });\n\n y -= lineHeight;\n }\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n\n return {\n pageCount: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to add page to PDF\", \"PDF_ADD_PAGE_FAILED\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Get metadata from the PDF document\n * @returns PDF metadata including title, author, dates, and page count\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n * const metadata = await pdf.getMetadata();\n *\n * console.log(metadata.title);\n * console.log(metadata.author);\n * console.log(metadata.pageCount);\n * ```\n */\n public async getMetadata(): Promise<PDFMetadataResultType> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n updateMetadata: false,\n });\n\n return {\n title: pdfDoc.getTitle(),\n author: pdfDoc.getAuthor(),\n subject: pdfDoc.getSubject(),\n keywords: pdfDoc.getKeywords(),\n producer: pdfDoc.getProducer(),\n creator: pdfDoc.getCreator(),\n creationDate: pdfDoc.getCreationDate(),\n modificationDate: pdfDoc.getModificationDate(),\n pageCount: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to get PDF metadata\", \"PDF_METADATA_GET_FAILED\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Update metadata of an existing PDF document\n * @param options - Metadata options to update\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n * await pdf.updateMetadata({\n * title: \"Updated Title\",\n * author: \"New Author\",\n * subject: \"Updated Subject\",\n * keywords: [\"updated\", \"keywords\"],\n * producer: \"My App\",\n * creator: \"pdf-lib\",\n * creationDate: new Date(\"2020-01-01\"),\n * modificationDate: new Date(),\n * });\n * ```\n */\n public async updateMetadata(options: PDFUpdateMetadataOptionsType): Promise<void> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n if (options.title !== undefined) {\n pdfDoc.setTitle(options.title);\n }\n if (options.author !== undefined) {\n pdfDoc.setAuthor(options.author);\n }\n if (options.subject !== undefined) {\n pdfDoc.setSubject(options.subject);\n }\n if (options.keywords !== undefined) {\n pdfDoc.setKeywords(options.keywords);\n }\n if (options.producer !== undefined) {\n pdfDoc.setProducer(options.producer);\n }\n if (options.creator !== undefined) {\n pdfDoc.setCreator(options.creator);\n }\n if (options.creationDate !== undefined) {\n pdfDoc.setCreationDate(options.creationDate);\n }\n if (options.modificationDate !== undefined) {\n pdfDoc.setModificationDate(options.modificationDate);\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to update PDF metadata\", \"PDF_METADATA_UPDATE_FAILED\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Get the total number of pages in the PDF\n */\n public async getPageCount(): Promise<number> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n updateMetadata: false,\n });\n return pdfDoc.getPageCount();\n } catch (error) {\n throw new PDFException(\"Failed to get page count\", \"PDF_PAGE_COUNT_FAILED\", {\n source: this.source,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Get the text content of a specific page\n * @param pageNumber - Page number (1-indexed)\n * @returns Extracted text content from the page\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Get content from page 1\n * const content = await pdf.getPageContent(1);\n * console.log(content); // \"Lorem ipsum dolor sit amet...\"\n *\n * // Get content from a specific page\n * const page3Content = await pdf.getPageContent(3);\n * console.log(page3Content); // Plain text content\n * ```\n */\n public async getPageContent(pageNumber: number): Promise<string> {\n if (pageNumber < 1 || !Number.isInteger(pageNumber)) {\n throw new PDFException(\"Page number must be a positive integer\", \"PDF_INVALID_PAGE_NUMBER\", {\n pageNumber,\n });\n }\n\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n const document = await getDocumentProxy(new Uint8Array(sourceBytes));\n const totalPages = document.numPages;\n\n if (pageNumber > totalPages) {\n throw new PDFException(\"Page number exceeds total pages\", \"PDF_PAGE_OUT_OF_RANGE\", {\n pageNumber,\n totalPages,\n });\n }\n\n const page = await document.getPage(pageNumber);\n const textContent = await page.getTextContent();\n const text = textContent.items\n .filter((item) => \"str\" in item)\n .map((item) => (\"hasEOL\" in item && item.hasEOL ? `${item.str}\\n` : item.str))\n .join(\"\");\n\n return text.trim();\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to get page content\", \"PDF_PAGE_CONTENT_FAILED\", {\n source: this.source,\n pageNumber,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Extract images from PDF pages and save to disk\n * @param options - Options including output directory, optional prefix, and optional page number\n * @returns Result containing total pages and array of extracted images with file paths\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Extract images from all pages\n * const images = await pdf.getImages({ outputDir: \"/output\" });\n * console.log(`Found ${images.length} images`);\n *\n * // Extract images from a specific page\n * const page1Images = await pdf.getImages({ outputDir: \"/output\", prefix: \"doc\", pageNumber: 1 });\n * for (const image of page1Images) {\n * console.log(`Image: ${image.path}, ${image.width}x${image.height}`);\n * }\n * ```\n */\n public async getImages(options: PDFGetImagesOptionsType): Promise<PDFGetImagesResultType> {\n const { pageNumber } = options;\n\n if (pageNumber !== undefined && (pageNumber < 1 || !Number.isInteger(pageNumber))) {\n throw new PDFException(\"Page number must be a positive integer\", \"PDF_INVALID_PAGE_NUMBER\", {\n pageNumber,\n });\n }\n\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"image\";\n\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n const document = await getDocumentProxy(new Uint8Array(sourceBytes));\n const totalPages = document.numPages;\n\n if (pageNumber !== undefined && pageNumber > totalPages) {\n throw new PDFException(\"Page number exceeds total pages\", \"PDF_PAGE_OUT_OF_RANGE\", {\n pageNumber,\n totalPages,\n });\n }\n\n const processPage = async (page: number) => {\n const pageImages = await extractImages(document, page);\n const results: PDFExtractedImageType[] = [];\n let imageIndex = 0;\n for (const img of pageImages) {\n imageIndex++;\n const fileName = `${prefix}-p${page}-${imageIndex}.png`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n // Convert raw image data to PNG using sharp\n const pngBuffer = await sharp(img.data, {\n raw: {\n width: img.width,\n height: img.height,\n channels: img.channels,\n },\n })\n .png()\n .toBuffer();\n\n await Bun.write(filePath, pngBuffer);\n\n results.push({\n page,\n path: filePath,\n width: img.width,\n height: img.height,\n });\n }\n return results;\n };\n\n if (pageNumber !== undefined) {\n return await processPage(pageNumber);\n }\n\n const allResults = await Promise.all(Array.from({ length: totalPages }, (_, i) => processPage(i + 1)));\n return allResults.flat();\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to extract images from PDF\", \"PDF_EXTRACT_IMAGES_FAILED\", {\n source: this.source,\n outputDir: normalizedOutputDir,\n pageNumber,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Convert all pages to images and save to disk\n * @param options - Options including output directory and optional prefix\n * @returns Array of page image results with page numbers and file paths\n */\n public async *pagesToImages(options: PDFToImagesOptionsType): AsyncGenerator<PDFPageImageResultType, void, unknown> {\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"page\";\n const savedWorker = (globalThis as Record<string, unknown>).pdfjsWorker;\n (globalThis as Record<string, unknown>).pdfjsWorker = undefined;\n\n try {\n const document = await pdf(this.source, this.options);\n let pageNumber = 1;\n\n for await (const image of document) {\n const fileName = `${prefix}-${pageNumber}.png`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n await Bun.write(filePath, Buffer.from(image));\n\n yield {\n page: pageNumber,\n path: filePath,\n };\n pageNumber++;\n }\n\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n } catch (error) {\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n throw new PDFException(\"Failed to convert PDF to images\", \"PDF_CONVERT_IMAGES_FAILED\", {\n source: this.source,\n outputDir: normalizedOutputDir,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Convert a specific page to an image and save to disk\n * @param pageNumber - Page number (1-indexed)\n * @param options - Options including output directory and optional prefix\n * @returns Page image result with page number and file path\n */\n public async pageToImage(pageNumber: number, options: PDFToImagesOptionsType): Promise<PDFPageImageResultType> {\n if (pageNumber < 1 || !Number.isInteger(pageNumber)) {\n throw new PDFException(\"Page number must be a positive integer\", \"PDF_INVALID_PAGE_NUMBER\", {\n pageNumber,\n });\n }\n\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"page\";\n const savedWorker = (globalThis as Record<string, unknown>).pdfjsWorker;\n (globalThis as Record<string, unknown>).pdfjsWorker = undefined;\n\n try {\n const document = await pdf(this.source, this.options);\n\n if (pageNumber > document.length) {\n throw new PDFException(\"Page number exceeds total pages\", \"PDF_PAGE_OUT_OF_RANGE\", {\n pageNumber,\n totalPages: document.length,\n });\n }\n\n const image = await document.getPage(pageNumber);\n\n const fileName = `${prefix}-${pageNumber}.png`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n await Bun.write(filePath, Buffer.from(image));\n\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n\n return {\n page: pageNumber,\n path: filePath,\n };\n } catch (error) {\n (globalThis as Record<string, unknown>).pdfjsWorker = savedWorker;\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to get page image\", \"PDF_PAGE_IMAGE_FAILED\", {\n source: this.source,\n pageNumber,\n outputDir: normalizedOutputDir,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Split the PDF into separate documents and save to disk\n * @param options - Split options with output directory, page ranges, and optional prefix\n * @returns Array of split PDF results with page ranges and file paths\n */\n public async *split(options: PDFSplitOptionsType): AsyncGenerator<PDFSplitResultType, void, unknown> {\n const normalizedOutputDir = path.join(...options.outputDir.split(/[/\\\\]/));\n const prefix = options.prefix ?? \"page\";\n\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const sourcePdf = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n const totalPages = sourcePdf.getPageCount();\n\n if (totalPages === 0) {\n throw new PDFException(\"PDF has no pages\", \"PDF_NO_PAGES\", {\n source: this.source,\n });\n }\n\n const ranges = this.normalizeRanges(options.ranges, totalPages);\n\n // Validate all ranges first\n for (const { start, end } of ranges) {\n if (start < 1 || end > totalPages || start > end) {\n throw new PDFException(\"Invalid page range\", \"PDF_INVALID_PAGE_RANGE\", {\n start,\n end,\n totalPages,\n });\n }\n }\n\n for (const { start, end } of ranges) {\n const newPdf = await PDFDocument.create();\n const pageIndices = Array.from({ length: end - start + 1 }, (_, i) => start - 1 + i);\n const copiedPages = await newPdf.copyPages(sourcePdf, pageIndices);\n\n for (const page of copiedPages) {\n newPdf.addPage(page);\n }\n\n const pdfBytes = await newPdf.save();\n\n const fileName = start === end ? `${prefix}-${start}.pdf` : `${prefix}-${start}-${end}.pdf`;\n const filePath = path.join(normalizedOutputDir, fileName);\n\n await Bun.write(filePath, pdfBytes);\n\n yield {\n pages: { start, end },\n path: filePath,\n };\n }\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to split PDF\", \"PDF_SPLIT_FAILED\", {\n source: this.source,\n outputDir: normalizedOutputDir,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Remove specified pages from the PDF\n * @param pages - Page numbers to remove (1-indexed). Can be individual numbers or ranges [start, end]\n * @returns Result with remaining page count and PDF buffer\n *\n * @example\n * ```typescript\n * const pdf = new PDF(\"/path/to/document.pdf\");\n *\n * // Remove individual pages (pages 2 and 5)\n * const result1 = await pdf.removePages([2, 5]);\n *\n * // Remove a range of pages (pages 3 to 6)\n * const result2 = await pdf.removePages([[3, 6]]);\n *\n * // Remove mixed: individual pages and ranges (pages 1, 4-6, and 10)\n * const result3 = await pdf.removePages([1, [4, 6], 10]);\n *\n * console.log(result3.remainingPages); // Number of pages left\n * console.log(result3.buffer); // Buffer containing the resulting PDF\n *\n * // Save to file\n * await Bun.write(\"/path/to/output.pdf\", result3.buffer);\n * ```\n */\n public async removePages(pages: (number | [number, number])[]): Promise<PDFRemovePagesResultType> {\n try {\n const sourceBytes = await Bun.file(this.source).arrayBuffer();\n\n const pdfDoc = await PDFDocument.load(sourceBytes, {\n ignoreEncryption: this.options.password !== undefined,\n });\n\n const totalPages = pdfDoc.getPageCount();\n\n if (totalPages === 0) {\n throw new PDFException(\"PDF has no pages\", \"PDF_NO_PAGES\", {\n source: this.source,\n });\n }\n\n // Normalize page numbers to remove into a flat sorted array\n const pagesToRemove = this.normalizePageNumbers(pages, totalPages);\n\n if (pagesToRemove.length === 0) {\n throw new PDFException(\"No valid pages specified for removal\", \"PDF_NO_VALID_PAGES\", {\n pages,\n });\n }\n\n if (pagesToRemove.length >= totalPages) {\n throw new PDFException(\"Cannot remove all pages from PDF\", \"PDF_CANNOT_REMOVE_ALL_PAGES\", {\n pagesToRemove,\n totalPages,\n });\n }\n\n // Remove pages in reverse order to maintain correct indices\n const sortedDescending = [...pagesToRemove].sort((a, b) => b - a);\n for (const pageNum of sortedDescending) {\n pdfDoc.removePage(pageNum - 1); // Convert to 0-indexed\n }\n\n const pdfBytes = await pdfDoc.save();\n\n await Bun.write(this.source, pdfBytes);\n\n return {\n remainingPages: pdfDoc.getPageCount(),\n };\n } catch (error) {\n if (error instanceof PDFException) {\n throw error;\n }\n throw new PDFException(\"Failed to remove pages from PDF\", \"PDF_REMOVE_PAGES_FAILED\", {\n source: this.source,\n pages,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Normalize page numbers into a flat array of unique valid page numbers\n */\n private normalizePageNumbers(pages: (number | [number, number])[], totalPages: number): number[] {\n const pageSet = new Set<number>();\n\n for (const page of pages) {\n if (typeof page === \"number\") {\n if (page >= 1 && page <= totalPages && Number.isInteger(page)) {\n pageSet.add(page);\n }\n } else {\n const [start, end] = page;\n if (start <= end) {\n for (let i = Math.max(1, start); i <= Math.min(totalPages, end); i++) {\n if (Number.isInteger(i)) {\n pageSet.add(i);\n }\n }\n }\n }\n }\n\n return Array.from(pageSet);\n }\n\n /**\n * Normalize page ranges for splitting\n * If no ranges provided, creates individual page ranges\n */\n private normalizeRanges(\n ranges: PDFSplitOptionsType[\"ranges\"] | undefined,\n totalPages: number,\n ): { start: number; end: number }[] {\n if (!ranges || ranges.length === 0) {\n return Array.from({ length: totalPages }, (_, i) => ({\n start: i + 1,\n end: i + 1,\n }));\n }\n\n return ranges.map((range) => {\n if (typeof range === \"number\") {\n return { start: range, end: range };\n }\n return { start: range[0], end: range[1] };\n });\n }\n}\n",
|
|
6
|
+
"import { Exception } from \"@ooneex/exception\";\nimport { HttpStatus } from \"@ooneex/http-status\";\n\nexport class PDFException extends Exception {\n constructor(message: string, key: string, data: Record<string, unknown> = {}) {\n super(message, {\n key,\n status: HttpStatus.Code.InternalServerError,\n data,\n });\n this.name = \"PDFException\";\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;AAAA;AACA;AACA;AACA;AACA;;;ACJA;AACA;AAAA;AAEO,MAAM,qBAAqB,UAAU;AAAA,EAC1C,WAAW,CAAC,SAAiB,OAAgC,CAAC,GAAG;AAAA,IAC/D,MAAM,SAAS;AAAA,MACb,QAAQ,WAAW,KAAK;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,IACD,KAAK,OAAO;AAAA;AAEhB;;;ADcO,MAAM,IAAoB;AAAA,EACd;AAAA,EACA;AAAA,EAOjB,WAAW,CAAC,QAAgB,UAA0B,CAAC,GAAG;AAAA,IACxD,KAAK,SAAS,KAAK,KAAK,GAAG,OAAO,MAAM,OAAO,CAAC;AAAA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;AAAA,YACpE,IAAI,OAAO,UAAU,CAAC,GAAG;AAAA,cACvB,QAAQ,IAAI,CAAC;AAAA,YACf;AAAA,UACF;AAAA,QACF;AAAA;AAAA,IAEJ;AAAA,IAEA,OAAO,MAAM,KAAK,OAAO;AAAA;AAAA,EAOnB,eAAe,CACrB,QACA,YACkC;AAAA,IAClC,IAAI,CAAC,UAAU,OAAO,WAAW,GAAG;AAAA,MAClC,OAAO,MAAM,KAAK,EAAE,QAAQ,WAAW,GAAG,CAAC,GAAG,OAAO;AAAA,QACnD,OAAO,IAAI;AAAA,QACX,KAAK,IAAI;AAAA,MACX,EAAE;AAAA,IACJ;AAAA,IAEA,OAAO,OAAO,IAAI,CAAC,UAAU;AAAA,MAC3B,IAAI,OAAO,UAAU,UAAU;AAAA,QAC7B,OAAO,EAAE,OAAO,OAAO,KAAK,MAAM;AAAA,MACpC;AAAA,MACA,OAAO,EAAE,OAAO,MAAM,IAAI,KAAK,MAAM,GAAG;AAAA,KACzC;AAAA;AAEL;",
|
|
9
|
+
"debugId": "50118D49CA2A880B64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/pdf",
|
|
3
3
|
"description": "PDF document toolkit for generating, editing, merging, splitting, and converting PDF files to images with page-level content extraction",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"npm:publish": "bun publish --tolerate-republish --force --production --access public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ooneex/exception": "1.
|
|
32
|
-
"@ooneex/http-status": "1.1.
|
|
31
|
+
"@ooneex/exception": "1.2.0",
|
|
32
|
+
"@ooneex/http-status": "1.1.3",
|
|
33
33
|
"pdf-lib": "^1.17.1",
|
|
34
34
|
"pdf-to-img": "^5.0.0",
|
|
35
35
|
"sharp": "^0.34.0",
|