@embedpdf/models 1.0.12 → 1.0.13
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 +36 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +169 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -106,6 +106,41 @@ function restorePosition(containerSize, position, rotation, scaleFactor) {
|
|
|
106
106
|
1 / scaleFactor
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
|
+
function rectEquals(a, b) {
|
|
110
|
+
return a.origin.x === b.origin.x && a.origin.y === b.origin.y && a.size.width === b.size.width && a.size.height === b.size.height;
|
|
111
|
+
}
|
|
112
|
+
function rectFromPoints(positions) {
|
|
113
|
+
if (positions.length === 0) {
|
|
114
|
+
return { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } };
|
|
115
|
+
}
|
|
116
|
+
const xs = positions.map((p) => p.x);
|
|
117
|
+
const ys = positions.map((p) => p.y);
|
|
118
|
+
const minX = Math.min(...xs);
|
|
119
|
+
const minY = Math.min(...ys);
|
|
120
|
+
return {
|
|
121
|
+
origin: { x: minX, y: minY },
|
|
122
|
+
size: {
|
|
123
|
+
width: Math.max(...xs) - minX,
|
|
124
|
+
height: Math.max(...ys) - minY
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function rotateAndTranslatePoint(pos, angleRad, translate) {
|
|
129
|
+
const cos = Math.cos(angleRad);
|
|
130
|
+
const sin = Math.sin(angleRad);
|
|
131
|
+
const newX = pos.x * cos - pos.y * sin;
|
|
132
|
+
const newY = pos.x * sin + pos.y * cos;
|
|
133
|
+
return {
|
|
134
|
+
x: newX + translate.x,
|
|
135
|
+
y: newY + translate.y
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function expandRect(rect, padding) {
|
|
139
|
+
return {
|
|
140
|
+
origin: { x: rect.origin.x - padding, y: rect.origin.y - padding },
|
|
141
|
+
size: { width: rect.size.width + padding * 2, height: rect.size.height + padding * 2 }
|
|
142
|
+
};
|
|
143
|
+
}
|
|
109
144
|
function rotateRect(containerSize, rect, rotation) {
|
|
110
145
|
let x = rect.origin.x;
|
|
111
146
|
let y = rect.origin.y;
|
|
@@ -996,6 +1031,20 @@ var PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {
|
|
|
996
1031
|
PdfAnnotationStateModel2["Reviewed"] = "Reviewed";
|
|
997
1032
|
return PdfAnnotationStateModel2;
|
|
998
1033
|
})(PdfAnnotationStateModel || {});
|
|
1034
|
+
var PdfAnnotationLineEnding = /* @__PURE__ */ ((PdfAnnotationLineEnding2) => {
|
|
1035
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["None"] = 0] = "None";
|
|
1036
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Square"] = 1] = "Square";
|
|
1037
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Circle"] = 2] = "Circle";
|
|
1038
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Diamond"] = 3] = "Diamond";
|
|
1039
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["OpenArrow"] = 4] = "OpenArrow";
|
|
1040
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["ClosedArrow"] = 5] = "ClosedArrow";
|
|
1041
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Butt"] = 6] = "Butt";
|
|
1042
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["ROpenArrow"] = 7] = "ROpenArrow";
|
|
1043
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["RClosedArrow"] = 8] = "RClosedArrow";
|
|
1044
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Slash"] = 9] = "Slash";
|
|
1045
|
+
PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Unknown"] = 10] = "Unknown";
|
|
1046
|
+
return PdfAnnotationLineEnding2;
|
|
1047
|
+
})(PdfAnnotationLineEnding || {});
|
|
999
1048
|
var PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {
|
|
1000
1049
|
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
1001
1050
|
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["PUSHBUTTON"] = 1] = "PUSHBUTTON";
|
|
@@ -1317,6 +1366,7 @@ export {
|
|
|
1317
1366
|
PdfAnnotationColorType,
|
|
1318
1367
|
PdfAnnotationFlagName,
|
|
1319
1368
|
PdfAnnotationFlags,
|
|
1369
|
+
PdfAnnotationLineEnding,
|
|
1320
1370
|
PdfAnnotationObjectStatus,
|
|
1321
1371
|
PdfAnnotationState,
|
|
1322
1372
|
PdfAnnotationStateModel,
|
|
@@ -1356,6 +1406,7 @@ export {
|
|
|
1356
1406
|
compareSearchTarget,
|
|
1357
1407
|
cssToBlendMode,
|
|
1358
1408
|
dateToPdfDate,
|
|
1409
|
+
expandRect,
|
|
1359
1410
|
flagsToNames,
|
|
1360
1411
|
getBlendModeInfo,
|
|
1361
1412
|
ignore,
|
|
@@ -1364,11 +1415,14 @@ export {
|
|
|
1364
1415
|
pdfAlphaColorToWebAlphaColor,
|
|
1365
1416
|
pdfDateToDate,
|
|
1366
1417
|
quadToRect,
|
|
1418
|
+
rectEquals,
|
|
1419
|
+
rectFromPoints,
|
|
1367
1420
|
rectToQuad,
|
|
1368
1421
|
reduceBlendModes,
|
|
1369
1422
|
restoreOffset,
|
|
1370
1423
|
restorePosition,
|
|
1371
1424
|
restoreRect,
|
|
1425
|
+
rotateAndTranslatePoint,
|
|
1372
1426
|
rotatePosition,
|
|
1373
1427
|
rotateRect,
|
|
1374
1428
|
scalePosition,
|