@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.cjs
CHANGED
|
@@ -499,11 +499,7 @@ var PdfiumEngine = class {
|
|
|
499
499
|
const length = array.length;
|
|
500
500
|
const filePtr = this.malloc(length);
|
|
501
501
|
this.pdfiumModule.pdfium.HEAPU8.set(array, filePtr);
|
|
502
|
-
const
|
|
503
|
-
const passwordPtr = this.malloc(passwordBytesSize);
|
|
504
|
-
this.pdfiumModule.pdfium.stringToUTF8(password, passwordPtr, passwordBytesSize);
|
|
505
|
-
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, passwordPtr);
|
|
506
|
-
this.free(passwordPtr);
|
|
502
|
+
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, password);
|
|
507
503
|
if (!docPtr) {
|
|
508
504
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
509
505
|
this.logger.error(LOG_SOURCE, LOG_CATEGORY, `FPDF_LoadMemDocument failed with ${lastError}`);
|
|
@@ -519,7 +515,7 @@ var PdfiumEngine = class {
|
|
|
519
515
|
const sizePtr = this.malloc(8);
|
|
520
516
|
for (let index = 0; index < pageCount; index++) {
|
|
521
517
|
const result = this.pdfiumModule.FPDF_GetPageSizeByIndexF(docPtr, index, sizePtr);
|
|
522
|
-
if (result
|
|
518
|
+
if (!result) {
|
|
523
519
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
524
520
|
this.logger.error(
|
|
525
521
|
LOG_SOURCE,
|
|
@@ -528,7 +524,6 @@ var PdfiumEngine = class {
|
|
|
528
524
|
);
|
|
529
525
|
this.free(sizePtr);
|
|
530
526
|
this.pdfiumModule.FPDF_CloseDocument(docPtr);
|
|
531
|
-
this.free(passwordPtr);
|
|
532
527
|
this.free(filePtr);
|
|
533
528
|
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `OpenDocumentFromBuffer`, "End", file.id);
|
|
534
529
|
return import_models.PdfTaskHelper.reject({
|
|
@@ -586,11 +581,7 @@ var PdfiumEngine = class {
|
|
|
586
581
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr, fileLength, "i32");
|
|
587
582
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr + 4, callbackPtr, "i32");
|
|
588
583
|
this.pdfiumModule.pdfium.setValue(fileAccessPtr + 8, 0, "i32");
|
|
589
|
-
const
|
|
590
|
-
const passwordPtr = this.malloc(passwordBytesSize);
|
|
591
|
-
this.pdfiumModule.pdfium.stringToUTF8(password, passwordPtr, passwordBytesSize);
|
|
592
|
-
const docPtr = this.pdfiumModule.FPDF_LoadCustomDocument(fileAccessPtr, passwordPtr);
|
|
593
|
-
this.free(passwordPtr);
|
|
584
|
+
const docPtr = this.pdfiumModule.FPDF_LoadCustomDocument(fileAccessPtr, password);
|
|
594
585
|
if (!docPtr) {
|
|
595
586
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
596
587
|
this.logger.error(
|
|
@@ -610,7 +601,7 @@ var PdfiumEngine = class {
|
|
|
610
601
|
const sizePtr = this.malloc(8);
|
|
611
602
|
for (let index = 0; index < pageCount; index++) {
|
|
612
603
|
const result = this.pdfiumModule.FPDF_GetPageSizeByIndexF(docPtr, index, sizePtr);
|
|
613
|
-
if (result
|
|
604
|
+
if (!result) {
|
|
614
605
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
615
606
|
this.logger.error(
|
|
616
607
|
LOG_SOURCE,
|
|
@@ -619,7 +610,6 @@ var PdfiumEngine = class {
|
|
|
619
610
|
);
|
|
620
611
|
this.free(sizePtr);
|
|
621
612
|
this.pdfiumModule.FPDF_CloseDocument(docPtr);
|
|
622
|
-
this.free(passwordPtr);
|
|
623
613
|
this.free(fileAccessPtr);
|
|
624
614
|
this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `OpenDocumentFromLoader`, "End", file.id);
|
|
625
615
|
return import_models.PdfTaskHelper.reject({
|
|
@@ -1706,7 +1696,7 @@ var PdfiumEngine = class {
|
|
|
1706
1696
|
const length = array.length;
|
|
1707
1697
|
const filePtr = this.malloc(length);
|
|
1708
1698
|
this.pdfiumModule.pdfium.HEAPU8.set(array, filePtr);
|
|
1709
|
-
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length,
|
|
1699
|
+
const docPtr = this.pdfiumModule.FPDF_LoadMemDocument(filePtr, length, "");
|
|
1710
1700
|
if (!docPtr) {
|
|
1711
1701
|
const lastError = this.pdfiumModule.FPDF_GetLastError();
|
|
1712
1702
|
this.logger.error(
|
|
@@ -1726,7 +1716,7 @@ var PdfiumEngine = class {
|
|
|
1726
1716
|
});
|
|
1727
1717
|
}
|
|
1728
1718
|
ptrs.push({ filePtr, docPtr });
|
|
1729
|
-
if (!this.pdfiumModule.FPDF_ImportPages(newDocPtr, docPtr,
|
|
1719
|
+
if (!this.pdfiumModule.FPDF_ImportPages(newDocPtr, docPtr, "", 0)) {
|
|
1730
1720
|
this.pdfiumModule.FPDF_CloseDocument(newDocPtr);
|
|
1731
1721
|
for (const ptr of ptrs) {
|
|
1732
1722
|
this.pdfiumModule.FPDF_CloseDocument(ptr.docPtr);
|
|
@@ -1790,23 +1780,17 @@ var PdfiumEngine = class {
|
|
|
1790
1780
|
continue;
|
|
1791
1781
|
}
|
|
1792
1782
|
const pageString = validPageIndices.map((index) => index + 1).join(",");
|
|
1793
|
-
const pageStringPtr = this.malloc(pageString.length + 1);
|
|
1794
1783
|
try {
|
|
1795
|
-
for (let i = 0; i < pageString.length; i++) {
|
|
1796
|
-
this.pdfiumModule.pdfium.setValue(pageStringPtr + i, pageString.charCodeAt(i), "i8");
|
|
1797
|
-
}
|
|
1798
|
-
this.pdfiumModule.pdfium.setValue(pageStringPtr + pageString.length, 0, "i8");
|
|
1799
1784
|
if (!this.pdfiumModule.FPDF_ImportPages(
|
|
1800
1785
|
newDocPtr,
|
|
1801
1786
|
ctx.docPtr,
|
|
1802
|
-
|
|
1787
|
+
pageString,
|
|
1803
1788
|
0
|
|
1804
1789
|
// Insert at the beginning
|
|
1805
1790
|
)) {
|
|
1806
1791
|
throw new Error(`Failed to import pages ${pageString} from document ${config.docId}`);
|
|
1807
1792
|
}
|
|
1808
1793
|
} finally {
|
|
1809
|
-
this.free(pageStringPtr);
|
|
1810
1794
|
}
|
|
1811
1795
|
}
|
|
1812
1796
|
const buffer = this.saveDocument(newDocPtr);
|