@embedpdf/models 1.0.13 → 1.0.15

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
  *
@@ -490,6 +484,22 @@ export declare enum PdfAnnotationSubtype {
490
484
  * @public
491
485
  */
492
486
  export declare const PdfAnnotationSubtypeName: Record<PdfAnnotationSubtype, string>;
487
+ /**
488
+ * Context map for annotation subtypes
489
+ *
490
+ * @public
491
+ */
492
+ export interface AnnotationContextMap {
493
+ [PdfAnnotationSubtype.STAMP]: {
494
+ imageData: ImageData;
495
+ };
496
+ }
497
+ /**
498
+ * Context type for annotation subtypes
499
+ *
500
+ * @public
501
+ */
502
+ export type AnnotationCreateContext<A extends PdfAnnotationObject> = A['type'] extends keyof AnnotationContextMap ? AnnotationContextMap[A['type']] : undefined;
493
503
  /**
494
504
  * Status of pdf annotation
495
505
  *
@@ -642,6 +652,10 @@ export interface PdfAnnotationObjectBase {
642
652
  * Sub type of annotation
643
653
  */
644
654
  type: PdfAnnotationSubtype;
655
+ /**
656
+ * flags of the annotation
657
+ */
658
+ flags?: PdfAnnotationFlagName[];
645
659
  /**
646
660
  * The index of page that this annotation belong to
647
661
  */
@@ -1263,10 +1277,6 @@ export type PdfStampAnnoObjectContents = Array<PdfPathObject | PdfImageObject |
1263
1277
  export interface PdfStampAnnoObject extends PdfAnnotationObjectBase {
1264
1278
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
1265
1279
  type: PdfAnnotationSubtype.STAMP;
1266
- /**
1267
- * contents in this stamp annotation
1268
- */
1269
- contents: PdfStampAnnoObjectContents;
1270
1280
  }
1271
1281
  /**
1272
1282
  * Pdf circle annotation
@@ -1458,7 +1468,45 @@ export interface PdfCaretAnnoObject extends PdfAnnotationObjectBase {
1458
1468
  export interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
1459
1469
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
1460
1470
  type: PdfAnnotationSubtype.FREETEXT;
1471
+ /**
1472
+ * Text contents of the free text annotation
1473
+ */
1461
1474
  contents: string;
1475
+ /**
1476
+ * Font family of the free text annotation
1477
+ */
1478
+ fontFamily: PdfStandardFont;
1479
+ /**
1480
+ * Font size of the free text annotation
1481
+ */
1482
+ fontSize: number;
1483
+ /**
1484
+ * Font color of the free text annotation
1485
+ */
1486
+ fontColor: string;
1487
+ /**
1488
+ * Text alignment of the free text annotation
1489
+ */
1490
+ textAlign: PdfTextAlignment;
1491
+ /**
1492
+ * Vertical alignment of the free text annotation
1493
+ */
1494
+ verticalAlign: PdfVerticalAlignment;
1495
+ /**
1496
+ * Opacity of the free text annotation
1497
+ */
1498
+ opacity: number;
1499
+ /**
1500
+ * Background color of the free text annotation
1501
+ */
1502
+ backgroundColor?: string;
1503
+ /**
1504
+ * Default style of the free text annotation
1505
+ */
1506
+ defaultStyle?: string;
1507
+ /**
1508
+ * Rich content of the free text annotation
1509
+ */
1462
1510
  richContent?: string;
1463
1511
  }
1464
1512
  /**
@@ -2010,16 +2058,6 @@ export interface PdfEngine<T = Blob> {
2010
2058
  * @returns task contains the annotations or error
2011
2059
  */
2012
2060
  getPageAnnotations: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfAnnotationObject[]>;
2013
- /**
2014
- * Change the visible colour (and opacity) of an existing annotation.
2015
- * @param doc - pdf document
2016
- * @param page - pdf page
2017
- * @param annotation - the annotation to recolour
2018
- * @param colour - RGBA color values (0-255 per channel)
2019
- * @param which - 0 = stroke/fill colour (PDFium's "colourType" param)
2020
- * @returns task that indicates whether the operation succeeded
2021
- */
2022
- updateAnnotationColor: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number) => PdfTask<boolean>;
2023
2061
  /**
2024
2062
  * Create a annotation on specified page
2025
2063
  * @param doc - pdf document
@@ -2027,7 +2065,7 @@ export interface PdfEngine<T = Blob> {
2027
2065
  * @param annotation - new annotations
2028
2066
  * @returns task whether the annotations is created successfully
2029
2067
  */
2030
- createPageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<number>;
2068
+ createPageAnnotation: <A extends PdfAnnotationObject>(doc: PdfDocumentObject, page: PdfPageObject, annotation: A, context?: AnnotationCreateContext<A>) => PdfTask<number>;
2031
2069
  /**
2032
2070
  * Update a annotation on specified page
2033
2071
  * @param doc - pdf document
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/models",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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",