@embedpdf/models 2.1.2 → 2.3.0
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/geometry.d.ts +11 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +197 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -218,6 +218,7 @@ function restoreOffset(offset, rotation, scaleFactor) {
|
|
|
218
218
|
y: offsetY
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
+
const EMPTY_RECT = { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } };
|
|
221
222
|
function boundingRect(rects) {
|
|
222
223
|
if (rects.length === 0) return null;
|
|
223
224
|
let minX = rects[0].origin.x, minY = rects[0].origin.y, maxX = rects[0].origin.x + rects[0].size.width, maxY = rects[0].origin.y + rects[0].size.height;
|
|
@@ -238,6 +239,9 @@ function boundingRect(rects) {
|
|
|
238
239
|
}
|
|
239
240
|
};
|
|
240
241
|
}
|
|
242
|
+
function boundingRectOrEmpty(rects) {
|
|
243
|
+
return boundingRect(rects) ?? EMPTY_RECT;
|
|
244
|
+
}
|
|
241
245
|
function buildUserToDeviceMatrix(rect, rotation, outW, outH) {
|
|
242
246
|
const L = rect.origin.x;
|
|
243
247
|
const B = rect.origin.y;
|
|
@@ -1088,6 +1092,12 @@ var PdfAnnotationLineEnding = /* @__PURE__ */ ((PdfAnnotationLineEnding2) => {
|
|
|
1088
1092
|
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Unknown"] = 10] = "Unknown";
|
|
1089
1093
|
return PdfAnnotationLineEnding2;
|
|
1090
1094
|
})(PdfAnnotationLineEnding || {});
|
|
1095
|
+
var PdfAnnotationReplyType = /* @__PURE__ */ ((PdfAnnotationReplyType2) => {
|
|
1096
|
+
PdfAnnotationReplyType2[PdfAnnotationReplyType2["Unknown"] = 0] = "Unknown";
|
|
1097
|
+
PdfAnnotationReplyType2[PdfAnnotationReplyType2["Reply"] = 1] = "Reply";
|
|
1098
|
+
PdfAnnotationReplyType2[PdfAnnotationReplyType2["Group"] = 2] = "Group";
|
|
1099
|
+
return PdfAnnotationReplyType2;
|
|
1100
|
+
})(PdfAnnotationReplyType || {});
|
|
1091
1101
|
var PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {
|
|
1092
1102
|
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
1093
1103
|
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["PUSHBUTTON"] = 1] = "PUSHBUTTON";
|
|
@@ -1273,17 +1283,34 @@ function compareSearchTarget(targetA, targetB) {
|
|
|
1273
1283
|
const flagB = unionFlags(targetB.flags);
|
|
1274
1284
|
return flagA === flagB && targetA.keyword === targetB.keyword;
|
|
1275
1285
|
}
|
|
1276
|
-
var
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1286
|
+
var PdfPermissionFlag = /* @__PURE__ */ ((PdfPermissionFlag2) => {
|
|
1287
|
+
PdfPermissionFlag2[PdfPermissionFlag2["Print"] = 4] = "Print";
|
|
1288
|
+
PdfPermissionFlag2[PdfPermissionFlag2["ModifyContents"] = 8] = "ModifyContents";
|
|
1289
|
+
PdfPermissionFlag2[PdfPermissionFlag2["CopyContents"] = 16] = "CopyContents";
|
|
1290
|
+
PdfPermissionFlag2[PdfPermissionFlag2["ModifyAnnotations"] = 32] = "ModifyAnnotations";
|
|
1291
|
+
PdfPermissionFlag2[PdfPermissionFlag2["FillForms"] = 256] = "FillForms";
|
|
1292
|
+
PdfPermissionFlag2[PdfPermissionFlag2["ExtractForAccessibility"] = 512] = "ExtractForAccessibility";
|
|
1293
|
+
PdfPermissionFlag2[PdfPermissionFlag2["AssembleDocument"] = 1024] = "AssembleDocument";
|
|
1294
|
+
PdfPermissionFlag2[PdfPermissionFlag2["PrintHighQuality"] = 2048] = "PrintHighQuality";
|
|
1295
|
+
PdfPermissionFlag2[PdfPermissionFlag2["AllowAll"] = 3900] = "AllowAll";
|
|
1296
|
+
return PdfPermissionFlag2;
|
|
1297
|
+
})(PdfPermissionFlag || {});
|
|
1298
|
+
function buildPermissions(...flags) {
|
|
1299
|
+
let result = flags.reduce((acc, flag) => acc | flag, 0);
|
|
1300
|
+
if (result & 2048) {
|
|
1301
|
+
result |= 4;
|
|
1302
|
+
}
|
|
1303
|
+
return result;
|
|
1304
|
+
}
|
|
1305
|
+
class PermissionDeniedError extends Error {
|
|
1306
|
+
constructor(requiredFlags, currentPermissions) {
|
|
1307
|
+
const flagNames = requiredFlags.map((f) => PdfPermissionFlag[f]).join(", ");
|
|
1308
|
+
super(`Permission denied. Required: ${flagNames}`);
|
|
1309
|
+
this.requiredFlags = requiredFlags;
|
|
1310
|
+
this.currentPermissions = currentPermissions;
|
|
1311
|
+
this.name = "PermissionDeniedError";
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1287
1314
|
var PdfPageFlattenFlag = /* @__PURE__ */ ((PdfPageFlattenFlag2) => {
|
|
1288
1315
|
PdfPageFlattenFlag2[PdfPageFlattenFlag2["Display"] = 0] = "Display";
|
|
1289
1316
|
PdfPageFlattenFlag2[PdfPageFlattenFlag2["Print"] = 1] = "Print";
|
|
@@ -2012,6 +2039,7 @@ export {
|
|
|
2012
2039
|
PdfAnnotationIcon,
|
|
2013
2040
|
PdfAnnotationLineEnding,
|
|
2014
2041
|
PdfAnnotationObjectStatus,
|
|
2042
|
+
PdfAnnotationReplyType,
|
|
2015
2043
|
PdfAnnotationState,
|
|
2016
2044
|
PdfAnnotationStateModel,
|
|
2017
2045
|
PdfAnnotationSubtype,
|
|
@@ -2026,7 +2054,7 @@ export {
|
|
|
2026
2054
|
PdfPageFlattenFlag,
|
|
2027
2055
|
PdfPageFlattenResult,
|
|
2028
2056
|
PdfPageObjectType,
|
|
2029
|
-
|
|
2057
|
+
PdfPermissionFlag,
|
|
2030
2058
|
PdfSegmentObjectType,
|
|
2031
2059
|
PdfSoftHyphenMarker,
|
|
2032
2060
|
PdfStampFit,
|
|
@@ -2042,6 +2070,7 @@ export {
|
|
|
2042
2070
|
PdfZeroWidthSpace,
|
|
2043
2071
|
PdfZoomMode,
|
|
2044
2072
|
PerfLogger,
|
|
2073
|
+
PermissionDeniedError,
|
|
2045
2074
|
Rotation,
|
|
2046
2075
|
STANDARD_FONT_FAMILIES,
|
|
2047
2076
|
Task,
|
|
@@ -2053,6 +2082,8 @@ export {
|
|
|
2053
2082
|
blendModeToCss,
|
|
2054
2083
|
blendModeValues,
|
|
2055
2084
|
boundingRect,
|
|
2085
|
+
boundingRectOrEmpty,
|
|
2086
|
+
buildPermissions,
|
|
2056
2087
|
buildUserToDeviceMatrix,
|
|
2057
2088
|
calculateAngle,
|
|
2058
2089
|
calculateDegree,
|