@embedpdf/engines 1.0.1 → 1.0.3
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/{chunk-NDTYBBMQ.js → chunk-FXQUMVH5.js} +8 -24
- package/dist/chunk-FXQUMVH5.js.map +1 -0
- package/dist/index.cjs +7 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/pdfium.cjs +7 -23
- package/dist/pdfium.cjs.map +1 -1
- package/dist/pdfium.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-NDTYBBMQ.js.map +0 -1
package/dist/index.js
CHANGED
package/dist/pdfium.cjs
CHANGED
|
@@ -493,11 +493,7 @@ var PdfiumEngine = class {
|
|
|
493
493
|
const length = array.length;
|
|
494
494
|
const filePtr = this.malloc(length);
|
|
495
495
|
this.pdfiumModule.pdfium.HEAPU8.set(array, filePtr);
|
|
496
|
-
const
|
|
497
|
-
const passwordPtr = this.malloc(passwordBytesSize);
|
|
498
|
-
this.pdfiumModule.pdfium.stringToUTF8(password, passwordPtr, passwordBytesSize);
|
|
499
|
-
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, passwordPtr);
|
|
500
|
-
this.free(passwordPtr);
|
|
496
|
+
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, password);
|
|
501
497
|
if (!docPtr) {
|
|
502
498
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
503
499
|
this.logger.error(LOG_SOURCE, LOG_CATEGORY, `FPDF_LoadMemDocument failed with ${lastError}`);
|
|
@@ -513,7 +509,7 @@ var PdfiumEngine = class {
|
|
|
513
509
|
const sizePtr = this.malloc(8);
|
|
514
510
|
for (let index = 0; index < pageCount; index++) {
|
|
515
511
|
const result = this.pdfiumModule.FPDF_GetPageSizeByIndexF(docPtr, index, sizePtr);
|
|
516
|
-
if (result
|
|
512
|
+
if (!result) {
|
|
517
513
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
518
514
|
this.logger.error(
|
|
519
515
|
LOG_SOURCE,
|
|
@@ -522,7 +518,6 @@ var PdfiumEngine = class {
|
|
|
522
518
|
);
|
|
523
519
|
this.free(sizePtr);
|
|
524
520
|
this.pdfiumModule.FPDF_CloseDocument(docPtr);
|
|
525
|
-
this.free(passwordPtr);
|
|
526
521
|
this.free(filePtr);
|
|
527
522
|
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `OpenDocumentFromBuffer`, "End", file.id);
|
|
528
523
|
return import_models.PdfTaskHelper.reject({
|
|
@@ -580,11 +575,7 @@ var PdfiumEngine = class {
|
|
|
580
575
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr, fileLength, "i32");
|
|
581
576
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr + 4, callbackPtr, "i32");
|
|
582
577
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr + 8, 0, "i32");
|
|
583
|
-
const
|
|
584
|
-
const passwordPtr = this.malloc(passwordBytesSize);
|
|
585
|
-
this.pdfiumModule.pdfium.stringToUTF8(password, passwordPtr, passwordBytesSize);
|
|
586
|
-
const docPtr = this.pdfiumModule.FPDF_LoadCustomDocument(fileAccessPtr, passwordPtr);
|
|
587
|
-
this.free(passwordPtr);
|
|
578
|
+
const docPtr = this.pdfiumModule.FPDF_LoadCustomDocument(fileAccessPtr, password);
|
|
588
579
|
if (!docPtr) {
|
|
589
580
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
590
581
|
this.logger.error(
|
|
@@ -604,7 +595,7 @@ var PdfiumEngine = class {
|
|
|
604
595
|
const sizePtr = this.malloc(8);
|
|
605
596
|
for (let index = 0; index < pageCount; index++) {
|
|
606
597
|
const result = this.pdfiumModule.FPDF_GetPageSizeByIndexF(docPtr, index, sizePtr);
|
|
607
|
-
if (result
|
|
598
|
+
if (!result) {
|
|
608
599
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
609
600
|
this.logger.error(
|
|
610
601
|
LOG_SOURCE,
|
|
@@ -613,7 +604,6 @@ var PdfiumEngine = class {
|
|
|
613
604
|
);
|
|
614
605
|
this.free(sizePtr);
|
|
615
606
|
this.pdfiumModule.FPDF_CloseDocument(docPtr);
|
|
616
|
-
this.free(passwordPtr);
|
|
617
607
|
this.free(fileAccessPtr);
|
|
618
608
|
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `OpenDocumentFromLoader`, "End", file.id);
|
|
619
609
|
return import_models.PdfTaskHelper.reject({
|
|
@@ -1700,7 +1690,7 @@ var PdfiumEngine = class {
|
|
|
1700
1690
|
const length = array.length;
|
|
1701
1691
|
const filePtr = this.malloc(length);
|
|
1702
1692
|
this.pdfiumModule.pdfium.HEAPU8.set(array, filePtr);
|
|
1703
|
-
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length,
|
|
1693
|
+
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, "");
|
|
1704
1694
|
if (!docPtr) {
|
|
1705
1695
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
1706
1696
|
this.logger.error(
|
|
@@ -1720,7 +1710,7 @@ var PdfiumEngine = class {
|
|
|
1720
1710
|
});
|
|
1721
1711
|
}
|
|
1722
1712
|
ptrs.push({ filePtr, docPtr });
|
|
1723
|
-
if (!this.pdfiumModule.FPDF_ImportPages(newDocPtr, docPtr,
|
|
1713
|
+
if (!this.pdfiumModule.FPDF_ImportPages(newDocPtr, docPtr, "", 0)) {
|
|
1724
1714
|
this.pdfiumModule.FPDF_CloseDocument(newDocPtr);
|
|
1725
1715
|
for (const ptr of ptrs) {
|
|
1726
1716
|
this.pdfiumModule.FPDF_CloseDocument(ptr.docPtr);
|
|
@@ -1784,23 +1774,17 @@ var PdfiumEngine = class {
|
|
|
1784
1774
|
continue;
|
|
1785
1775
|
}
|
|
1786
1776
|
const pageString = validPageIndices.map((index) => index + 1).join(",");
|
|
1787
|
-
const pageStringPtr = this.malloc(pageString.length + 1);
|
|
1788
1777
|
try {
|
|
1789
|
-
for (let i = 0; i < pageString.length; i++) {
|
|
1790
|
-
this.pdfiumModule.pdfium.setValue(pageStringPtr + i, pageString.charCodeAt(i), "i8");
|
|
1791
|
-
}
|
|
1792
|
-
this.pdfiumModule.pdfium.setValue(pageStringPtr + pageString.length, 0, "i8");
|
|
1793
1778
|
if (!this.pdfiumModule.FPDF_ImportPages(
|
|
1794
1779
|
newDocPtr,
|
|
1795
1780
|
ctx.docPtr,
|
|
1796
|
-
|
|
1781
|
+
pageString,
|
|
1797
1782
|
0
|
|
1798
1783
|
// Insert at the beginning
|
|
1799
1784
|
)) {
|
|
1800
1785
|
throw new Error(`Failed to import pages ${pageString} from document ${config.docId}`);
|
|
1801
1786
|
}
|
|
1802
1787
|
} finally {
|
|
1803
|
-
this.free(pageStringPtr);
|
|
1804
1788
|
}
|
|
1805
1789
|
}
|
|
1806
1790
|
const buffer = this.saveDocument(newDocPtr);
|