@embedpdf/models 1.0.12 → 1.0.14

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/pdf.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { WebAlphaColor } from './color';
2
1
  import { Size, Rect, Position, Rotation } from './geometry';
3
2
  import { Task, TaskError } from './task';
4
3
  /**
@@ -171,6 +170,42 @@ export declare enum PdfZoomMode {
171
170
  */
172
171
  FitRectangle = 5
173
172
  }
173
+ /**
174
+ * 12 default fonts for PDF
175
+ */
176
+ export declare enum PdfStandardFont {
177
+ Unknown = -1,
178
+ Courier = 0,
179
+ Courier_Bold = 1,
180
+ Courier_BoldOblique = 2,
181
+ Courier_Oblique = 3,
182
+ Helvetica = 4,
183
+ Helvetica_Bold = 5,
184
+ Helvetica_BoldOblique = 6,
185
+ Helvetica_Oblique = 7,
186
+ Times_Roman = 8,
187
+ Times_Bold = 9,
188
+ Times_BoldItalic = 10,
189
+ Times_Italic = 11,
190
+ Symbol = 12,
191
+ ZapfDingbats = 13
192
+ }
193
+ /**
194
+ * Text alignment
195
+ */
196
+ export declare enum PdfTextAlignment {
197
+ Left = 0,
198
+ Center = 1,
199
+ Right = 2
200
+ }
201
+ /**
202
+ * Vertical alignment
203
+ */
204
+ export declare enum PdfVerticalAlignment {
205
+ Top = 0,
206
+ Middle = 1,
207
+ Bottom = 2
208
+ }
174
209
  /**
175
210
  * Blend mode
176
211
  *
@@ -194,57 +229,6 @@ export declare enum PdfBlendMode {
194
229
  Color = 14,
195
230
  Luminosity = 15
196
231
  }
197
- /** Extra UI sentinel for “multiple different values selected”. */
198
- export declare const MixedBlendMode: unique symbol;
199
- export type UiBlendModeValue = PdfBlendMode | typeof MixedBlendMode;
200
- export type CssBlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
201
- interface BlendModeInfo {
202
- /** Pdf enum value */
203
- id: PdfBlendMode;
204
- /** Human label for UI */
205
- label: string;
206
- /** CSS mix-blend-mode token */
207
- css: CssBlendMode;
208
- }
209
- /** Get descriptor (falls back to Normal if unknown number sneaks in).
210
- *
211
- * @public
212
- */
213
- export declare function getBlendModeInfo(mode: PdfBlendMode): BlendModeInfo;
214
- /** Convert enum → CSS value for `mix-blend-mode`.
215
- *
216
- * @public
217
- */
218
- export declare function blendModeToCss(mode: PdfBlendMode): CssBlendMode;
219
- /** Convert CSS token → enum (returns undefined if not recognized).
220
- *
221
- * @public
222
- */
223
- export declare function cssToBlendMode(value: CssBlendMode): PdfBlendMode | undefined;
224
- /** Enum → UI label.
225
- *
226
- * @public
227
- */
228
- export declare function blendModeLabel(mode: PdfBlendMode): string;
229
- /**
230
- * For a selection of annotations: returns the common enum value, or Mixed sentinel.
231
- *
232
- * @public
233
- */
234
- export declare function reduceBlendModes(modes: readonly PdfBlendMode[]): UiBlendModeValue;
235
- /** Options for a <select>.
236
- *
237
- * @public
238
- */
239
- export declare const blendModeSelectOptions: {
240
- value: PdfBlendMode;
241
- label: string;
242
- }[];
243
- /** Provide a label when Mixed sentinel used (UI convenience).
244
- *
245
- * @public
246
- */
247
- export declare function uiBlendModeDisplay(value: UiBlendModeValue): string;
248
232
  /**
249
233
  * Representation of the linked destination
250
234
  *
@@ -448,6 +432,16 @@ export interface PdfAlphaColor {
448
432
  */
449
433
  alpha: number;
450
434
  }
435
+ /**
436
+ * Color
437
+ *
438
+ * @public
439
+ */
440
+ export interface PdfColor {
441
+ red: number;
442
+ green: number;
443
+ blue: number;
444
+ }
451
445
  /**
452
446
  * Annotation type
453
447
  *
@@ -565,6 +559,57 @@ export declare enum PdfAnnotationStateModel {
565
559
  */
566
560
  Reviewed = "Reviewed"
567
561
  }
562
+ /**
563
+ * Line ending of annotation
564
+ *
565
+ * @public
566
+ */
567
+ export declare enum PdfAnnotationLineEnding {
568
+ /**
569
+ * No line ending
570
+ */
571
+ None = 0,
572
+ /**
573
+ * Square line ending
574
+ */
575
+ Square = 1,
576
+ /**
577
+ * Circle line ending
578
+ */
579
+ Circle = 2,
580
+ /**
581
+ * Diamond line ending
582
+ */
583
+ Diamond = 3,
584
+ /**
585
+ * Open arrow line ending
586
+ */
587
+ OpenArrow = 4,
588
+ /**
589
+ * Closed arrow line ending
590
+ */
591
+ ClosedArrow = 5,
592
+ /**
593
+ * Butt line ending
594
+ */
595
+ Butt = 6,
596
+ /**
597
+ * Right open arrow line ending
598
+ */
599
+ ROpenArrow = 7,
600
+ /**
601
+ * Right closed arrow line ending
602
+ */
603
+ RClosedArrow = 8,
604
+ /**
605
+ * Slash line ending
606
+ */
607
+ Slash = 9,
608
+ /**
609
+ * Unknown line ending
610
+ */
611
+ Unknown = 10
612
+ }
568
613
  /**
569
614
  * Basic information of pdf annotation
570
615
  *
@@ -810,6 +855,24 @@ export declare enum PdfPageObjectType {
810
855
  SHADING = 4,
811
856
  FORM = 5
812
857
  }
858
+ /**
859
+ * Line points
860
+ *
861
+ * @public
862
+ */
863
+ export interface LinePoints {
864
+ start: Position;
865
+ end: Position;
866
+ }
867
+ /**
868
+ * Line endings
869
+ *
870
+ * @public
871
+ */
872
+ export interface LineEndings {
873
+ start: PdfAnnotationLineEnding;
874
+ end: PdfAnnotationLineEnding;
875
+ }
813
876
  /**
814
877
  * Options of pdf widget annotation
815
878
  *
@@ -930,10 +993,38 @@ export interface PdfInkAnnoObject extends PdfAnnotationObjectBase {
930
993
  export interface PdfPolygonAnnoObject extends PdfAnnotationObjectBase {
931
994
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
932
995
  type: PdfAnnotationSubtype.POLYGON;
996
+ /**
997
+ * contents of polygon annotation
998
+ */
999
+ contents?: string;
933
1000
  /**
934
1001
  * vertices of annotation
935
1002
  */
936
1003
  vertices: Position[];
1004
+ /**
1005
+ * color of ink annotation
1006
+ */
1007
+ color: string;
1008
+ /**
1009
+ * opacity of ink annotation
1010
+ */
1011
+ opacity: number;
1012
+ /**
1013
+ * stroke-width of ink annotation
1014
+ */
1015
+ strokeWidth: number;
1016
+ /**
1017
+ * stroke color of polygon annotation
1018
+ */
1019
+ strokeColor: string;
1020
+ /**
1021
+ * stroke style of polygon annotation
1022
+ */
1023
+ strokeStyle: PdfAnnotationBorderStyle;
1024
+ /**
1025
+ * stroke dash array of polygon annotation
1026
+ */
1027
+ strokeDashArray?: number[];
937
1028
  }
938
1029
  /**
939
1030
  * PDF polyline annotation
@@ -943,10 +1034,42 @@ export interface PdfPolygonAnnoObject extends PdfAnnotationObjectBase {
943
1034
  export interface PdfPolylineAnnoObject extends PdfAnnotationObjectBase {
944
1035
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
945
1036
  type: PdfAnnotationSubtype.POLYLINE;
1037
+ /**
1038
+ * contents of polyline annotation
1039
+ */
1040
+ contents?: string;
1041
+ /**
1042
+ * start and end line endings of polyline
1043
+ */
1044
+ lineEndings?: LineEndings;
946
1045
  /**
947
1046
  * vertices of annotation
948
1047
  */
949
1048
  vertices: Position[];
1049
+ /**
1050
+ * interior color of line annotation
1051
+ */
1052
+ color: string;
1053
+ /**
1054
+ * opacity of ink annotation
1055
+ */
1056
+ opacity: number;
1057
+ /**
1058
+ * stroke-width of ink annotation
1059
+ */
1060
+ strokeWidth: number;
1061
+ /**
1062
+ * stroke color of line annotation
1063
+ */
1064
+ strokeColor: string;
1065
+ /**
1066
+ * stroke style of polyline annotation
1067
+ */
1068
+ strokeStyle: PdfAnnotationBorderStyle;
1069
+ /**
1070
+ * stroke dash array of polyline annotation
1071
+ */
1072
+ strokeDashArray?: number[];
950
1073
  }
951
1074
  /**
952
1075
  * PDF line annotation
@@ -957,13 +1080,41 @@ export interface PdfLineAnnoObject extends PdfAnnotationObjectBase {
957
1080
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
958
1081
  type: PdfAnnotationSubtype.LINE;
959
1082
  /**
960
- * start point of line
1083
+ * contents of line annotation
1084
+ */
1085
+ contents?: string;
1086
+ /**
1087
+ * start and end points of line
1088
+ */
1089
+ linePoints: LinePoints;
1090
+ /**
1091
+ * start and end line endings of line
1092
+ */
1093
+ lineEndings?: LineEndings;
1094
+ /**
1095
+ * interior color of line annotation
1096
+ */
1097
+ color: string;
1098
+ /**
1099
+ * opacity of ink annotation
1100
+ */
1101
+ opacity: number;
1102
+ /**
1103
+ * stroke-width of ink annotation
1104
+ */
1105
+ strokeWidth: number;
1106
+ /**
1107
+ * stroke color of line annotation
961
1108
  */
962
- startPoint: Position;
1109
+ strokeColor: string;
963
1110
  /**
964
- * end point of line
1111
+ * stroke style of line annotation
965
1112
  */
966
- endPoint: Position;
1113
+ strokeStyle: PdfAnnotationBorderStyle;
1114
+ /**
1115
+ * stroke dash array of line annotation
1116
+ */
1117
+ strokeDashArray?: number[];
967
1118
  }
968
1119
  /**
969
1120
  * PDF highlight annotation
@@ -1123,6 +1274,10 @@ export interface PdfCircleAnnoObject extends PdfAnnotationObjectBase {
1123
1274
  * flags of circle annotation
1124
1275
  */
1125
1276
  flags: PdfAnnotationFlagName[];
1277
+ /**
1278
+ * Text contents of the circle annotation
1279
+ */
1280
+ contents?: string;
1126
1281
  /**
1127
1282
  * color of circle annotation
1128
1283
  */
@@ -1164,6 +1319,10 @@ export interface PdfCircleAnnoObject extends PdfAnnotationObjectBase {
1164
1319
  export interface PdfSquareAnnoObject extends PdfAnnotationObjectBase {
1165
1320
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
1166
1321
  type: PdfAnnotationSubtype.SQUARE;
1322
+ /**
1323
+ * Text contents of the square annotation
1324
+ */
1325
+ contents?: string;
1167
1326
  /**
1168
1327
  * flags of square annotation
1169
1328
  */
@@ -1293,7 +1452,45 @@ export interface PdfCaretAnnoObject extends PdfAnnotationObjectBase {
1293
1452
  export interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
1294
1453
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
1295
1454
  type: PdfAnnotationSubtype.FREETEXT;
1455
+ /**
1456
+ * Text contents of the free text annotation
1457
+ */
1296
1458
  contents: string;
1459
+ /**
1460
+ * Font family of the free text annotation
1461
+ */
1462
+ fontFamily: PdfStandardFont;
1463
+ /**
1464
+ * Font size of the free text annotation
1465
+ */
1466
+ fontSize: number;
1467
+ /**
1468
+ * Font color of the free text annotation
1469
+ */
1470
+ fontColor: string;
1471
+ /**
1472
+ * Text alignment of the free text annotation
1473
+ */
1474
+ textAlign: PdfTextAlignment;
1475
+ /**
1476
+ * Vertical alignment of the free text annotation
1477
+ */
1478
+ verticalAlign: PdfVerticalAlignment;
1479
+ /**
1480
+ * Opacity of the free text annotation
1481
+ */
1482
+ opacity: number;
1483
+ /**
1484
+ * Background color of the free text annotation
1485
+ */
1486
+ backgroundColor?: string;
1487
+ /**
1488
+ * Default style of the free text annotation
1489
+ */
1490
+ defaultStyle?: string;
1491
+ /**
1492
+ * Rich content of the free text annotation
1493
+ */
1297
1494
  richContent?: string;
1298
1495
  }
1299
1496
  /**
@@ -1845,16 +2042,6 @@ export interface PdfEngine<T = Blob> {
1845
2042
  * @returns task contains the annotations or error
1846
2043
  */
1847
2044
  getPageAnnotations: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfAnnotationObject[]>;
1848
- /**
1849
- * Change the visible colour (and opacity) of an existing annotation.
1850
- * @param doc - pdf document
1851
- * @param page - pdf page
1852
- * @param annotation - the annotation to recolour
1853
- * @param colour - RGBA color values (0-255 per channel)
1854
- * @param which - 0 = stroke/fill colour (PDFium's "colourType" param)
1855
- * @returns task that indicates whether the operation succeeded
1856
- */
1857
- updateAnnotationColor: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number) => PdfTask<boolean>;
1858
2045
  /**
1859
2046
  * Create a annotation on specified page
1860
2047
  * @param doc - pdf document
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/models",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "private": false,
5
5
  "description": "Shared type definitions, data models, and utility helpers (geometry, tasks, logging, PDF primitives) that underpin every package in the EmbedPDF ecosystem.",
6
6
  "type": "module",