@embedpdf/engines 1.2.1 → 1.3.1

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.
Files changed (36) hide show
  1. package/dist/{engine-4h8XG4y4.js → engine-BVe88qdX.js} +399 -27
  2. package/dist/engine-BVe88qdX.js.map +1 -0
  3. package/dist/engine-Cg0lRKs3.cjs +2 -0
  4. package/dist/engine-Cg0lRKs3.cjs.map +1 -0
  5. package/dist/{index-B7jrDsc1.js → index-B4mOT1hM.js} +15 -3
  6. package/dist/{index-B7jrDsc1.js.map → index-B4mOT1hM.js.map} +1 -1
  7. package/dist/index-dNJf04Wj.cjs +2 -0
  8. package/dist/index-dNJf04Wj.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +14 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/pdfium/engine.d.ts +72 -1
  14. package/dist/lib/pdfium/index.cjs +1 -1
  15. package/dist/lib/pdfium/index.js +2 -2
  16. package/dist/lib/pdfium/web/direct-engine.cjs +1 -1
  17. package/dist/lib/pdfium/web/direct-engine.js +1 -1
  18. package/dist/lib/pdfium/web/worker-engine.cjs +1 -1
  19. package/dist/lib/pdfium/web/worker-engine.js +1 -1
  20. package/dist/lib/webworker/engine.cjs +1 -1
  21. package/dist/lib/webworker/engine.cjs.map +1 -1
  22. package/dist/lib/webworker/engine.d.ts +25 -1
  23. package/dist/lib/webworker/engine.js +52 -0
  24. package/dist/lib/webworker/engine.js.map +1 -1
  25. package/dist/preact/index.cjs +1 -1
  26. package/dist/preact/index.js +1 -1
  27. package/dist/react/index.cjs +1 -1
  28. package/dist/react/index.js +1 -1
  29. package/dist/vue/index.cjs +1 -1
  30. package/dist/vue/index.js +1 -1
  31. package/package.json +4 -4
  32. package/dist/engine-4h8XG4y4.js.map +0 -1
  33. package/dist/engine-CJwS0wio.cjs +0 -2
  34. package/dist/engine-CJwS0wio.cjs.map +0 -1
  35. package/dist/index-C_vtp8q4.cjs +0 -2
  36. package/dist/index-C_vtp8q4.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { NoopLogger, PdfTaskHelper, PdfErrorCode, pdfDateToDate, ignore, isUuidV4, uuidV4, PdfAnnotationSubtype, PdfPageFlattenFlag, stripPdfUnwantedMarkers, PdfAnnotationIcon, PdfAnnotationBorderStyle, PdfAnnotationColorType, PdfAnnotationLineEnding, PdfStampFit, PdfTrappedStatus, pdfColorToWebColor, webColorToPdfColor, pdfAlphaToWebOpacity, webOpacityToPdfAlpha, dateToPdfDate, quadToRect, rectToQuad, PdfStandardFont, PdfPageObjectType, flagsToNames, namesToFlags, PDF_FORM_FIELD_TYPE, Rotation, AppearanceMode, Task, toIntRect, transformRect, buildUserToDeviceMatrix, PdfActionType, PdfZoomMode, MatchFlag } from "@embedpdf/models";
1
+ import { NoopLogger, PdfTaskHelper, PdfErrorCode, pdfDateToDate, ignore, isUuidV4, uuidV4, PdfAnnotationSubtype, PdfPageFlattenFlag, stripPdfUnwantedMarkers, PdfAnnotationIcon, PdfAnnotationBorderStyle, PdfAnnotationColorType, PdfAnnotationLineEnding, PdfStampFit, PdfTrappedStatus, pdfColorToWebColor, webColorToPdfColor, pdfAlphaToWebOpacity, webOpacityToPdfAlpha, dateToPdfDate, quadToRect, rectToQuad, PdfStandardFont, PdfPageObjectType, flagsToNames, namesToFlags, PDF_FORM_FIELD_TYPE, Rotation, AppearanceMode, Task, toIntRect, transformRect, buildUserToDeviceMatrix, PdfZoomMode, PdfActionType, MatchFlag } from "@embedpdf/models";
2
2
  function readString(wasmModule, readChars, parseChars, defaultLength = 100) {
3
3
  let buffer = wasmModule.wasmExports.malloc(defaultLength);
4
4
  for (let i = 0; i < defaultLength; i++) {
@@ -514,6 +514,33 @@ class PdfiumEngine {
514
514
  this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `Destroy`, "End", "General");
515
515
  return PdfTaskHelper.resolve(true);
516
516
  }
517
+ /** Write a UTF-16LE (WIDESTRING) to wasm, call `fn(ptr)`, then free. */
518
+ withWString(value, fn) {
519
+ const length = (value.length + 1) * 2;
520
+ const ptr = this.memoryManager.malloc(length);
521
+ try {
522
+ this.pdfiumModule.pdfium.stringToUTF16(value, ptr, length);
523
+ return fn(ptr);
524
+ } finally {
525
+ this.memoryManager.free(ptr);
526
+ }
527
+ }
528
+ /** Write a float[] to wasm, call `fn(ptr, count)`, then free. */
529
+ withFloatArray(values, fn) {
530
+ const arr = values ?? [];
531
+ const bytes = arr.length * 4;
532
+ const ptr = bytes ? this.memoryManager.malloc(bytes) : WasmPointer(0);
533
+ try {
534
+ if (bytes) {
535
+ for (let i = 0; i < arr.length; i++) {
536
+ this.pdfiumModule.pdfium.setValue(ptr + i * 4, arr[i], "float");
537
+ }
538
+ }
539
+ return fn(ptr, arr.length);
540
+ } finally {
541
+ if (bytes) this.memoryManager.free(ptr);
542
+ }
543
+ }
517
544
  /**
518
545
  * {@inheritDoc @embedpdf/models!PdfEngine.openDocumentUrl}
519
546
  *
@@ -1014,6 +1041,85 @@ class PdfiumEngine {
1014
1041
  bookmarks
1015
1042
  });
1016
1043
  }
1044
+ /**
1045
+ * {@inheritDoc @embedpdf/models!PdfEngine.setBookmarks}
1046
+ *
1047
+ * @public
1048
+ */
1049
+ setBookmarks(doc, list) {
1050
+ this.logger.debug(LOG_SOURCE, LOG_CATEGORY, "setBookmarks", doc, list);
1051
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `SetBookmarks`, "Begin", doc.id);
1052
+ const ctx = this.cache.getContext(doc.id);
1053
+ if (!ctx) {
1054
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `SetBookmarks`, "End", doc.id);
1055
+ return PdfTaskHelper.reject({
1056
+ code: PdfErrorCode.DocNotOpen,
1057
+ message: "document does not open"
1058
+ });
1059
+ }
1060
+ if (!this.pdfiumModule.EPDFBookmark_Clear(ctx.docPtr)) {
1061
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `SetBookmarks`, "End", doc.id);
1062
+ return PdfTaskHelper.reject({
1063
+ code: PdfErrorCode.Unknown,
1064
+ message: "failed to clear existing bookmarks"
1065
+ });
1066
+ }
1067
+ const build = (parentPtr, items) => {
1068
+ var _a;
1069
+ for (const item of items) {
1070
+ const bmPtr = this.withWString(
1071
+ item.title ?? "",
1072
+ (wptr) => this.pdfiumModule.EPDFBookmark_AppendChild(ctx.docPtr, parentPtr, wptr)
1073
+ );
1074
+ if (!bmPtr) return false;
1075
+ if (item.target) {
1076
+ const ok2 = this.applyBookmarkTarget(ctx.docPtr, bmPtr, item.target);
1077
+ if (!ok2) return false;
1078
+ }
1079
+ if ((_a = item.children) == null ? void 0 : _a.length) {
1080
+ const ok2 = build(bmPtr, item.children);
1081
+ if (!ok2) return false;
1082
+ }
1083
+ }
1084
+ return true;
1085
+ };
1086
+ const ok = build(
1087
+ /*top-level*/
1088
+ 0,
1089
+ list
1090
+ );
1091
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `SetBookmarks`, "End", doc.id);
1092
+ if (!ok) {
1093
+ return PdfTaskHelper.reject({
1094
+ code: PdfErrorCode.Unknown,
1095
+ message: "failed to build bookmark tree"
1096
+ });
1097
+ }
1098
+ return PdfTaskHelper.resolve(true);
1099
+ }
1100
+ /**
1101
+ * {@inheritDoc @embedpdf/models!PdfEngine.deleteBookmarks}
1102
+ *
1103
+ * @public
1104
+ */
1105
+ deleteBookmarks(doc) {
1106
+ this.logger.debug(LOG_SOURCE, LOG_CATEGORY, "deleteBookmarks", doc);
1107
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteBookmarks`, "Begin", doc.id);
1108
+ const ctx = this.cache.getContext(doc.id);
1109
+ if (!ctx) {
1110
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteBookmarks`, "End", doc.id);
1111
+ return PdfTaskHelper.reject({
1112
+ code: PdfErrorCode.DocNotOpen,
1113
+ message: "document does not open"
1114
+ });
1115
+ }
1116
+ const ok = this.pdfiumModule.EPDFBookmark_Clear(ctx.docPtr);
1117
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteBookmarks`, "End", doc.id);
1118
+ return ok ? PdfTaskHelper.resolve(true) : PdfTaskHelper.reject({
1119
+ code: PdfErrorCode.Unknown,
1120
+ message: "failed to clear bookmarks"
1121
+ });
1122
+ }
1017
1123
  /**
1018
1124
  * {@inheritDoc @embedpdf/models!PdfEngine.renderPage}
1019
1125
  *
@@ -1576,6 +1682,111 @@ class PdfiumEngine {
1576
1682
  this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `GetAttachments`, "End", doc.id);
1577
1683
  return PdfTaskHelper.resolve(attachments);
1578
1684
  }
1685
+ /**
1686
+ * {@inheritDoc @embedpdf/models!PdfEngine.addAttachment}
1687
+ *
1688
+ * @public
1689
+ */
1690
+ addAttachment(doc, params) {
1691
+ this.logger.debug(LOG_SOURCE, LOG_CATEGORY, "addAttachment", doc, params == null ? void 0 : params.name);
1692
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "Begin", doc.id);
1693
+ const ctx = this.cache.getContext(doc.id);
1694
+ if (!ctx) {
1695
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "End", doc.id);
1696
+ return PdfTaskHelper.reject({
1697
+ code: PdfErrorCode.DocNotOpen,
1698
+ message: "document does not open"
1699
+ });
1700
+ }
1701
+ const { name, description, mimeType, data } = params ?? {};
1702
+ if (!name) {
1703
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "End", doc.id);
1704
+ return PdfTaskHelper.reject({
1705
+ code: PdfErrorCode.NotFound,
1706
+ message: "attachment name is required"
1707
+ });
1708
+ }
1709
+ if (!data || (data instanceof Uint8Array ? data.byteLength === 0 : data.byteLength === 0)) {
1710
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "End", doc.id);
1711
+ return PdfTaskHelper.reject({
1712
+ code: PdfErrorCode.NotFound,
1713
+ message: "attachment data is empty"
1714
+ });
1715
+ }
1716
+ const attachmentPtr = this.withWString(
1717
+ name,
1718
+ (wNamePtr) => this.pdfiumModule.FPDFDoc_AddAttachment(ctx.docPtr, wNamePtr)
1719
+ );
1720
+ if (!attachmentPtr) {
1721
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "End", doc.id);
1722
+ return PdfTaskHelper.reject({
1723
+ code: PdfErrorCode.Unknown,
1724
+ message: `An attachment named "${name}" already exists`
1725
+ });
1726
+ }
1727
+ this.withWString(
1728
+ description,
1729
+ (wDescriptionPtr) => this.pdfiumModule.EPDFAttachment_SetDescription(attachmentPtr, wDescriptionPtr)
1730
+ );
1731
+ this.pdfiumModule.EPDFAttachment_SetSubtype(attachmentPtr, mimeType);
1732
+ const u8 = data instanceof Uint8Array ? data : new Uint8Array(data);
1733
+ const len = u8.byteLength;
1734
+ const contentPtr = this.memoryManager.malloc(len);
1735
+ try {
1736
+ this.pdfiumModule.pdfium.HEAPU8.set(u8, contentPtr);
1737
+ const ok = this.pdfiumModule.FPDFAttachment_SetFile(
1738
+ attachmentPtr,
1739
+ ctx.docPtr,
1740
+ contentPtr,
1741
+ len
1742
+ );
1743
+ if (!ok) {
1744
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "End", doc.id);
1745
+ return PdfTaskHelper.reject({
1746
+ code: PdfErrorCode.Unknown,
1747
+ message: "failed to write attachment bytes"
1748
+ });
1749
+ }
1750
+ } finally {
1751
+ this.memoryManager.free(contentPtr);
1752
+ }
1753
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `AddAttachment`, "End", doc.id);
1754
+ return PdfTaskHelper.resolve(true);
1755
+ }
1756
+ /**
1757
+ * {@inheritDoc @embedpdf/models!PdfEngine.removeAttachment}
1758
+ *
1759
+ * @public
1760
+ */
1761
+ removeAttachment(doc, attachment) {
1762
+ this.logger.debug(LOG_SOURCE, LOG_CATEGORY, "deleteAttachment", doc, attachment);
1763
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteAttachment`, "Begin", doc.id);
1764
+ const ctx = this.cache.getContext(doc.id);
1765
+ if (!ctx) {
1766
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteAttachment`, "End", doc.id);
1767
+ return PdfTaskHelper.reject({
1768
+ code: PdfErrorCode.DocNotOpen,
1769
+ message: "document does not open"
1770
+ });
1771
+ }
1772
+ const count = this.pdfiumModule.FPDFDoc_GetAttachmentCount(ctx.docPtr);
1773
+ if (attachment.index < 0 || attachment.index >= count) {
1774
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteAttachment`, "End", doc.id);
1775
+ return PdfTaskHelper.reject({
1776
+ code: PdfErrorCode.Unknown,
1777
+ message: `attachment index ${attachment.index} out of range`
1778
+ });
1779
+ }
1780
+ const ok = this.pdfiumModule.FPDFDoc_DeleteAttachment(ctx.docPtr, attachment.index);
1781
+ this.logger.perf(LOG_SOURCE, LOG_CATEGORY, `DeleteAttachment`, "End", doc.id);
1782
+ if (!ok) {
1783
+ return PdfTaskHelper.reject({
1784
+ code: PdfErrorCode.Unknown,
1785
+ message: "failed to delete attachment"
1786
+ });
1787
+ }
1788
+ return PdfTaskHelper.resolve(true);
1789
+ }
1579
1790
  /**
1580
1791
  * {@inheritDoc @embedpdf/models!PdfEngine.readAttachmentContent}
1581
1792
  *
@@ -3741,6 +3952,29 @@ class PdfiumEngine {
3741
3952
  const raw = dateToPdfDate(date);
3742
3953
  return this.setAnnotString(annotationPtr, key, raw);
3743
3954
  }
3955
+ /**
3956
+ * Get the date of the attachment
3957
+ *
3958
+ * @param attachmentPtr - pointer to an `FPDF_ATTACHMENT`
3959
+ * @param key - 'ModDate' for modified date, 'CreationDate' for creation date
3960
+ * @returns `Date` or `undefined` when PDFium can't read the date
3961
+ */
3962
+ getAttachmentDate(attachmentPtr, key) {
3963
+ const raw = this.getAttachmentString(attachmentPtr, key);
3964
+ return raw ? pdfDateToDate(raw) : void 0;
3965
+ }
3966
+ /**
3967
+ * Set the date of the attachment
3968
+ *
3969
+ * @param attachmentPtr - pointer to an `FPDF_ATTACHMENT`
3970
+ * @param key - 'ModDate' for modified date, 'CreationDate' for creation date
3971
+ * @param date - `Date` to set
3972
+ * @returns `true` on success
3973
+ */
3974
+ setAttachmentDate(attachmentPtr, key, date) {
3975
+ const raw = dateToPdfDate(date);
3976
+ return this.setAttachmentString(attachmentPtr, key, raw);
3977
+ }
3744
3978
  /**
3745
3979
  * Dash-pattern helper ( /BS → /D array, dashed borders only )
3746
3980
  *
@@ -5132,6 +5366,45 @@ class PdfiumEngine {
5132
5366
  this.memoryManager.free(ptr);
5133
5367
  return value || void 0;
5134
5368
  }
5369
+ /**
5370
+ * Get a string value (`/T`, `/M`, `/State`, …) from an attachment.
5371
+ *
5372
+ * @returns decoded UTF-8 string or `undefined` when the key is absent
5373
+ *
5374
+ * @private
5375
+ */
5376
+ getAttachmentString(attachmentPtr, key) {
5377
+ const len = this.pdfiumModule.FPDFAttachment_GetStringValue(attachmentPtr, key, 0, 0);
5378
+ if (len === 0) return;
5379
+ const bytes = (len + 1) * 2;
5380
+ const ptr = this.memoryManager.malloc(bytes);
5381
+ this.pdfiumModule.FPDFAttachment_GetStringValue(attachmentPtr, key, ptr, bytes);
5382
+ const value = this.pdfiumModule.pdfium.UTF16ToString(ptr);
5383
+ this.memoryManager.free(ptr);
5384
+ return value || void 0;
5385
+ }
5386
+ /**
5387
+ * Get a number value (`/Size`) from an attachment.
5388
+ *
5389
+ * @returns number or `null` when the key is absent
5390
+ *
5391
+ * @private
5392
+ */
5393
+ getAttachmentNumber(attachmentPtr, key) {
5394
+ const outPtr = this.memoryManager.malloc(4);
5395
+ try {
5396
+ const ok = this.pdfiumModule.EPDFAttachment_GetIntegerValue(
5397
+ attachmentPtr,
5398
+ key,
5399
+ // FPDF_BYTESTRING → ASCII JS string is fine in your glue
5400
+ outPtr
5401
+ );
5402
+ if (!ok) return void 0;
5403
+ return this.pdfiumModule.pdfium.getValue(outPtr, "i32") >>> 0;
5404
+ } finally {
5405
+ this.memoryManager.free(outPtr);
5406
+ }
5407
+ }
5135
5408
  /**
5136
5409
  * Get custom data of the annotation
5137
5410
  * @param annotationPtr - pointer to pdf annotation
@@ -5223,12 +5496,9 @@ class PdfiumEngine {
5223
5496
  * @private
5224
5497
  */
5225
5498
  getAnnotationByName(pagePtr, name) {
5226
- const bytes = 2 * (name.length + 1);
5227
- const ptr = this.memoryManager.malloc(bytes);
5228
- this.pdfiumModule.pdfium.stringToUTF16(name, ptr, bytes);
5229
- const ok = this.pdfiumModule.EPDFPage_GetAnnotByName(pagePtr, ptr);
5230
- this.memoryManager.free(ptr);
5231
- return ok;
5499
+ return this.withWString(name, (wNamePtr) => {
5500
+ return this.pdfiumModule.EPDFPage_GetAnnotByName(pagePtr, wNamePtr);
5501
+ });
5232
5502
  }
5233
5503
  /**
5234
5504
  * Remove annotation by name
@@ -5239,12 +5509,9 @@ class PdfiumEngine {
5239
5509
  * @private
5240
5510
  */
5241
5511
  removeAnnotationByName(pagePtr, name) {
5242
- const bytes = 2 * (name.length + 1);
5243
- const ptr = this.memoryManager.malloc(bytes);
5244
- this.pdfiumModule.pdfium.stringToUTF16(name, ptr, bytes);
5245
- const ok = this.pdfiumModule.EPDFPage_RemoveAnnotByName(pagePtr, ptr);
5246
- this.memoryManager.free(ptr);
5247
- return ok;
5512
+ return this.withWString(name, (wNamePtr) => {
5513
+ return this.pdfiumModule.EPDFPage_RemoveAnnotByName(pagePtr, wNamePtr);
5514
+ });
5248
5515
  }
5249
5516
  /**
5250
5517
  * Set a string value (`/T`, `/M`, `/State`, …) to an annotation.
@@ -5254,12 +5521,21 @@ class PdfiumEngine {
5254
5521
  * @private
5255
5522
  */
5256
5523
  setAnnotString(annotationPtr, key, value) {
5257
- const bytes = 2 * (value.length + 1);
5258
- const ptr = this.memoryManager.malloc(bytes);
5259
- this.pdfiumModule.pdfium.stringToUTF16(value, ptr, bytes);
5260
- const ok = this.pdfiumModule.FPDFAnnot_SetStringValue(annotationPtr, key, ptr);
5261
- this.memoryManager.free(ptr);
5262
- return ok;
5524
+ return this.withWString(value, (wValPtr) => {
5525
+ return this.pdfiumModule.FPDFAnnot_SetStringValue(annotationPtr, key, wValPtr);
5526
+ });
5527
+ }
5528
+ /**
5529
+ * Set a string value (`/T`, `/M`, `/State`, …) to an attachment.
5530
+ *
5531
+ * @returns `true` if the operation was successful
5532
+ *
5533
+ * @private
5534
+ */
5535
+ setAttachmentString(attachmentPtr, key, value) {
5536
+ return this.withWString(value, (wValPtr) => {
5537
+ return this.pdfiumModule.FPDFAttachment_SetStringValue(attachmentPtr, key, wValPtr);
5538
+ });
5263
5539
  }
5264
5540
  /**
5265
5541
  * Read vertices of pdf annotation
@@ -5759,6 +6035,95 @@ class PdfiumEngine {
5759
6035
  }
5760
6036
  }
5761
6037
  }
6038
+ createLocalDestPtr(docPtr, dest) {
6039
+ var _a, _b;
6040
+ const pagePtr = this.pdfiumModule.FPDF_LoadPage(docPtr, dest.pageIndex);
6041
+ if (!pagePtr) return 0;
6042
+ try {
6043
+ if (dest.zoom.mode === PdfZoomMode.XYZ) {
6044
+ const { x, y, zoom } = dest.zoom.params;
6045
+ return this.pdfiumModule.EPDFDest_CreateXYZ(
6046
+ pagePtr,
6047
+ /*has_left*/
6048
+ true,
6049
+ x,
6050
+ /*has_top*/
6051
+ true,
6052
+ y,
6053
+ /*has_zoom*/
6054
+ true,
6055
+ zoom
6056
+ );
6057
+ }
6058
+ let viewEnum;
6059
+ let params = [];
6060
+ switch (dest.zoom.mode) {
6061
+ case PdfZoomMode.FitPage:
6062
+ viewEnum = PdfZoomMode.FitPage;
6063
+ break;
6064
+ case PdfZoomMode.FitHorizontal:
6065
+ viewEnum = PdfZoomMode.FitHorizontal;
6066
+ params = [((_a = dest.view) == null ? void 0 : _a[0]) ?? 0];
6067
+ break;
6068
+ case PdfZoomMode.FitVertical:
6069
+ viewEnum = PdfZoomMode.FitVertical;
6070
+ params = [((_b = dest.view) == null ? void 0 : _b[0]) ?? 0];
6071
+ break;
6072
+ case PdfZoomMode.FitRectangle:
6073
+ {
6074
+ const v = dest.view ?? [];
6075
+ params = [v[0] ?? 0, v[1] ?? 0, v[2] ?? 0, v[3] ?? 0];
6076
+ viewEnum = PdfZoomMode.FitRectangle;
6077
+ }
6078
+ break;
6079
+ case PdfZoomMode.Unknown:
6080
+ default:
6081
+ return 0;
6082
+ }
6083
+ return this.withFloatArray(
6084
+ params,
6085
+ (ptr, count) => this.pdfiumModule.EPDFDest_CreateView(pagePtr, viewEnum, ptr, count)
6086
+ );
6087
+ } finally {
6088
+ this.pdfiumModule.FPDF_ClosePage(pagePtr);
6089
+ }
6090
+ }
6091
+ applyBookmarkTarget(docPtr, bmPtr, target) {
6092
+ if (target.type === "destination") {
6093
+ const destPtr = this.createLocalDestPtr(docPtr, target.destination);
6094
+ if (!destPtr) return false;
6095
+ const ok = this.pdfiumModule.EPDFBookmark_SetDest(docPtr, bmPtr, destPtr);
6096
+ return !!ok;
6097
+ }
6098
+ const action = target.action;
6099
+ switch (action.type) {
6100
+ case PdfActionType.Goto: {
6101
+ const destPtr = this.createLocalDestPtr(docPtr, action.destination);
6102
+ if (!destPtr) return false;
6103
+ const actPtr = this.pdfiumModule.EPDFAction_CreateGoTo(docPtr, destPtr);
6104
+ if (!actPtr) return false;
6105
+ return !!this.pdfiumModule.EPDFBookmark_SetAction(docPtr, bmPtr, actPtr);
6106
+ }
6107
+ case PdfActionType.URI: {
6108
+ const actPtr = this.pdfiumModule.EPDFAction_CreateURI(docPtr, action.uri);
6109
+ if (!actPtr) return false;
6110
+ return !!this.pdfiumModule.EPDFBookmark_SetAction(docPtr, bmPtr, actPtr);
6111
+ }
6112
+ case PdfActionType.LaunchAppOrOpenFile: {
6113
+ const actPtr = this.withWString(
6114
+ action.path,
6115
+ (wptr) => this.pdfiumModule.EPDFAction_CreateLaunch(docPtr, wptr)
6116
+ );
6117
+ if (!actPtr) return false;
6118
+ return !!this.pdfiumModule.EPDFBookmark_SetAction(docPtr, bmPtr, actPtr);
6119
+ }
6120
+ case PdfActionType.RemoteGoto:
6121
+ return false;
6122
+ case PdfActionType.Unsupported:
6123
+ default:
6124
+ return false;
6125
+ }
6126
+ }
5762
6127
  /**
5763
6128
  * Read pdf action from pdf document
5764
6129
  * @param docPtr - pointer to pdf document object
@@ -5949,18 +6314,21 @@ class PdfiumEngine {
5949
6314
  },
5950
6315
  this.pdfiumModule.pdfium.UTF16ToString
5951
6316
  );
5952
- const creationDate = readString(
6317
+ const description = readString(
5953
6318
  this.pdfiumModule.pdfium,
5954
6319
  (buffer, bufferLength) => {
5955
- return this.pdfiumModule.FPDFAttachment_GetStringValue(
5956
- attachmentPtr,
5957
- "CreationDate",
5958
- buffer,
5959
- bufferLength
5960
- );
6320
+ return this.pdfiumModule.EPDFAttachment_GetDescription(attachmentPtr, buffer, bufferLength);
5961
6321
  },
5962
6322
  this.pdfiumModule.pdfium.UTF16ToString
5963
6323
  );
6324
+ const mimeType = readString(
6325
+ this.pdfiumModule.pdfium,
6326
+ (buffer, bufferLength) => {
6327
+ return this.pdfiumModule.FPDFAttachment_GetSubtype(attachmentPtr, buffer, bufferLength);
6328
+ },
6329
+ this.pdfiumModule.pdfium.UTF16ToString
6330
+ );
6331
+ const creationDate = this.getAttachmentDate(attachmentPtr, "CreationDate");
5964
6332
  const checksum = readString(
5965
6333
  this.pdfiumModule.pdfium,
5966
6334
  (buffer, bufferLength) => {
@@ -5973,9 +6341,13 @@ class PdfiumEngine {
5973
6341
  },
5974
6342
  this.pdfiumModule.pdfium.UTF16ToString
5975
6343
  );
6344
+ const size = this.getAttachmentNumber(attachmentPtr, "Size");
5976
6345
  return {
5977
6346
  index,
5978
6347
  name,
6348
+ description,
6349
+ mimeType,
6350
+ size,
5979
6351
  creationDate,
5980
6352
  checksum
5981
6353
  };
@@ -6654,4 +7026,4 @@ export {
6654
7026
  isValidCustomKey as i,
6655
7027
  readString as r
6656
7028
  };
6657
- //# sourceMappingURL=engine-4h8XG4y4.js.map
7029
+ //# sourceMappingURL=engine-BVe88qdX.js.map