@embedpdf/engines 1.0.2 → 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
|
@@ -483,11 +483,7 @@ var PdfiumEngine = class {
|
|
|
483
483
|
const length = array.length;
|
|
484
484
|
const filePtr = this.malloc(length);
|
|
485
485
|
this.pdfiumModule.pdfium.HEAPU8.set(array, filePtr);
|
|
486
|
-
const
|
|
487
|
-
const passwordPtr = this.malloc(passwordBytesSize);
|
|
488
|
-
this.pdfiumModule.pdfium.stringToUTF8(password, passwordPtr, passwordBytesSize);
|
|
489
|
-
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, passwordPtr);
|
|
490
|
-
this.free(passwordPtr);
|
|
486
|
+
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, password);
|
|
491
487
|
if (!docPtr) {
|
|
492
488
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
493
489
|
this.logger.error(LOG_SOURCE, LOG_CATEGORY, `FPDF_LoadMemDocument failed with ${lastError}`);
|
|
@@ -503,7 +499,7 @@ var PdfiumEngine = class {
|
|
|
503
499
|
const sizePtr = this.malloc(8);
|
|
504
500
|
for (let index = 0; index < pageCount; index++) {
|
|
505
501
|
const result = this.pdfiumModule.FPDF_GetPageSizeByIndexF(docPtr, index, sizePtr);
|
|
506
|
-
if (result
|
|
502
|
+
if (!result) {
|
|
507
503
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
508
504
|
this.logger.error(
|
|
509
505
|
LOG_SOURCE,
|
|
@@ -512,7 +508,6 @@ var PdfiumEngine = class {
|
|
|
512
508
|
);
|
|
513
509
|
this.free(sizePtr);
|
|
514
510
|
this.pdfiumModule.FPDF_CloseDocument(docPtr);
|
|
515
|
-
this.free(passwordPtr);
|
|
516
511
|
this.free(filePtr);
|
|
517
512
|
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `OpenDocumentFromBuffer`, "End", file.id);
|
|
518
513
|
return PdfTaskHelper.reject({
|
|
@@ -570,11 +565,7 @@ var PdfiumEngine = class {
|
|
|
570
565
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr, fileLength, "i32");
|
|
571
566
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr + 4, callbackPtr, "i32");
|
|
572
567
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr + 8, 0, "i32");
|
|
573
|
-
const
|
|
574
|
-
const passwordPtr = this.malloc(passwordBytesSize);
|
|
575
|
-
this.pdfiumModule.pdfium.stringToUTF8(password, passwordPtr, passwordBytesSize);
|
|
576
|
-
const docPtr = this.pdfiumModule.FPDF_LoadCustomDocument(fileAccessPtr, passwordPtr);
|
|
577
|
-
this.free(passwordPtr);
|
|
568
|
+
const docPtr = this.pdfiumModule.FPDF_LoadCustomDocument(fileAccessPtr, password);
|
|
578
569
|
if (!docPtr) {
|
|
579
570
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
580
571
|
this.logger.error(
|
|
@@ -594,7 +585,7 @@ var PdfiumEngine = class {
|
|
|
594
585
|
const sizePtr = this.malloc(8);
|
|
595
586
|
for (let index = 0; index < pageCount; index++) {
|
|
596
587
|
const result = this.pdfiumModule.FPDF_GetPageSizeByIndexF(docPtr, index, sizePtr);
|
|
597
|
-
if (result
|
|
588
|
+
if (!result) {
|
|
598
589
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
599
590
|
this.logger.error(
|
|
600
591
|
LOG_SOURCE,
|
|
@@ -603,7 +594,6 @@ var PdfiumEngine = class {
|
|
|
603
594
|
);
|
|
604
595
|
this.free(sizePtr);
|
|
605
596
|
this.pdfiumModule.FPDF_CloseDocument(docPtr);
|
|
606
|
-
this.free(passwordPtr);
|
|
607
597
|
this.free(fileAccessPtr);
|
|
608
598
|
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `OpenDocumentFromLoader`, "End", file.id);
|
|
609
599
|
return PdfTaskHelper.reject({
|
|
@@ -1690,7 +1680,7 @@ var PdfiumEngine = class {
|
|
|
1690
1680
|
const length = array.length;
|
|
1691
1681
|
const filePtr = this.malloc(length);
|
|
1692
1682
|
this.pdfiumModule.pdfium.HEAPU8.set(array, filePtr);
|
|
1693
|
-
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length,
|
|
1683
|
+
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, "");
|
|
1694
1684
|
if (!docPtr) {
|
|
1695
1685
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
1696
1686
|
this.logger.error(
|
|
@@ -1710,7 +1700,7 @@ var PdfiumEngine = class {
|
|
|
1710
1700
|
});
|
|
1711
1701
|
}
|
|
1712
1702
|
ptrs.push({ filePtr, docPtr });
|
|
1713
|
-
if (!this.pdfiumModule.FPDF_ImportPages(newDocPtr, docPtr,
|
|
1703
|
+
if (!this.pdfiumModule.FPDF_ImportPages(newDocPtr, docPtr, "", 0)) {
|
|
1714
1704
|
this.pdfiumModule.FPDF_CloseDocument(newDocPtr);
|
|
1715
1705
|
for (const ptr of ptrs) {
|
|
1716
1706
|
this.pdfiumModule.FPDF_CloseDocument(ptr.docPtr);
|
|
@@ -1774,23 +1764,17 @@ var PdfiumEngine = class {
|
|
|
1774
1764
|
continue;
|
|
1775
1765
|
}
|
|
1776
1766
|
const pageString = validPageIndices.map((index) => index + 1).join(",");
|
|
1777
|
-
const pageStringPtr = this.malloc(pageString.length + 1);
|
|
1778
1767
|
try {
|
|
1779
|
-
for (let i = 0; i < pageString.length; i++) {
|
|
1780
|
-
this.pdfiumModule.pdfium.setValue(pageStringPtr + i, pageString.charCodeAt(i), "i8");
|
|
1781
|
-
}
|
|
1782
|
-
this.pdfiumModule.pdfium.setValue(pageStringPtr + pageString.length, 0, "i8");
|
|
1783
1768
|
if (!this.pdfiumModule.FPDF_ImportPages(
|
|
1784
1769
|
newDocPtr,
|
|
1785
1770
|
ctx.docPtr,
|
|
1786
|
-
|
|
1771
|
+
pageString,
|
|
1787
1772
|
0
|
|
1788
1773
|
// Insert at the beginning
|
|
1789
1774
|
)) {
|
|
1790
1775
|
throw new Error(`Failed to import pages ${pageString} from document ${config.docId}`);
|
|
1791
1776
|
}
|
|
1792
1777
|
} finally {
|
|
1793
|
-
this.free(pageStringPtr);
|
|
1794
1778
|
}
|
|
1795
1779
|
}
|
|
1796
1780
|
const buffer = this.saveDocument(newDocPtr);
|
|
@@ -4612,4 +4596,4 @@ export {
|
|
|
4612
4596
|
PdfiumEngine,
|
|
4613
4597
|
PdfiumEngineRunner
|
|
4614
4598
|
};
|
|
4615
|
-
//# sourceMappingURL=chunk-
|
|
4599
|
+
//# sourceMappingURL=chunk-FXQUMVH5.js.map
|