@embedpdf/models 2.2.0 → 2.4.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/pdf.d.ts CHANGED
@@ -829,6 +829,35 @@ export declare enum PdfAnnotationLineEnding {
829
829
  */
830
830
  Unknown = 10
831
831
  }
832
+ /**
833
+ * Reply type of annotation (RT property per ISO 32000-2)
834
+ *
835
+ * Specifies how an annotation relates to another annotation when it is
836
+ * a reply (via IRT - In Reply To). Valid values are:
837
+ * - Reply (/R): Normal comment reply (default if RT is missing)
838
+ * - Group (/Group): Logical grouping of annotations
839
+ *
840
+ * @public
841
+ */
842
+ export declare enum PdfAnnotationReplyType {
843
+ /**
844
+ * Unknown or invalid reply type
845
+ */
846
+ Unknown = 0,
847
+ /**
848
+ * /R - Comment reply (default if RT is missing)
849
+ * The annotation is a child comment of the annotation referenced by IRT.
850
+ * Used for comment threads, reviewer discussions, sticky-note replies.
851
+ */
852
+ Reply = 1,
853
+ /**
854
+ * /Group - Logical grouping
855
+ * The annotation is grouped with the annotation referenced by IRT.
856
+ * They represent the same logical object. Used when multiple annotations
857
+ * act as one unit (e.g., visual shape + metadata/label).
858
+ */
859
+ Group = 2
860
+ }
832
861
  /**
833
862
  * Basic information of pdf annotation
834
863
  *
@@ -883,6 +912,14 @@ export interface PdfAnnotationObjectBase {
883
912
  * Custom data of the annotation
884
913
  */
885
914
  custom?: any;
915
+ /**
916
+ * In reply to annotation id (IRT - for grouping or reply threads)
917
+ */
918
+ inReplyToId?: string;
919
+ /**
920
+ * Reply type (how this annotation relates to the parent via IRT)
921
+ */
922
+ replyType?: PdfAnnotationReplyType;
886
923
  }
887
924
  /**
888
925
  * Popup annotation
@@ -900,10 +937,6 @@ export interface PdfPopupAnnoObject extends PdfAnnotationObjectBase {
900
937
  * Whether the popup is opened or not
901
938
  */
902
939
  open: boolean;
903
- /**
904
- * In reply to id
905
- */
906
- inReplyToId?: string;
907
940
  }
908
941
  /**
909
942
  * Pdf Link annotation
@@ -917,6 +950,22 @@ export interface PdfLinkAnnoObject extends PdfAnnotationObjectBase {
917
950
  * target of the link
918
951
  */
919
952
  target: PdfLinkTarget | undefined;
953
+ /**
954
+ * Stroke color of the link border (e.g., "#00A5E4")
955
+ */
956
+ strokeColor?: string;
957
+ /**
958
+ * Width of the link border (default: 2)
959
+ */
960
+ strokeWidth?: number;
961
+ /**
962
+ * Style of the link border (default: UNDERLINE)
963
+ */
964
+ strokeStyle?: PdfAnnotationBorderStyle;
965
+ /**
966
+ * Dash pattern for dashed border style
967
+ */
968
+ strokeDashArray?: number[];
920
969
  }
921
970
  /**
922
971
  * Pdf Text annotation
@@ -938,10 +987,6 @@ export interface PdfTextAnnoObject extends PdfAnnotationObjectBase {
938
987
  * opacity of text annotation
939
988
  */
940
989
  opacity?: number;
941
- /**
942
- * In reply to id
943
- */
944
- inReplyToId?: string;
945
990
  /**
946
991
  * State of the text annotation
947
992
  */
@@ -1028,7 +1073,8 @@ export declare enum PDF_FORM_FIELD_TYPE {
1028
1073
  }
1029
1074
  export declare enum PdfAnnotationColorType {
1030
1075
  Color = 0,
1031
- InteriorColor = 1
1076
+ InteriorColor = 1,
1077
+ OverlayColor = 2
1032
1078
  }
1033
1079
  /**
1034
1080
  * Border style of pdf annotation
@@ -1208,9 +1254,13 @@ export interface PdfInkAnnoObject extends PdfAnnotationObjectBase {
1208
1254
  */
1209
1255
  inkList: PdfInkListObject[];
1210
1256
  /**
1211
- * color of ink annotation
1257
+ * Color of the ink stroke (preferred over deprecated `color`)
1212
1258
  */
1213
- color: string;
1259
+ strokeColor?: string;
1260
+ /**
1261
+ * @deprecated Use strokeColor instead. Will be removed in next major version.
1262
+ */
1263
+ color?: string;
1214
1264
  /**
1215
1265
  * opacity of ink annotation
1216
1266
  */
@@ -1364,9 +1414,13 @@ export interface PdfHighlightAnnoObject extends PdfAnnotationObjectBase {
1364
1414
  */
1365
1415
  contents?: string;
1366
1416
  /**
1367
- * color of highlight annotation
1417
+ * Color of the highlight markup (preferred over deprecated `color`)
1368
1418
  */
1369
- color: string;
1419
+ strokeColor?: string;
1420
+ /**
1421
+ * @deprecated Use strokeColor instead. Will be removed in next major version.
1422
+ */
1423
+ color?: string;
1370
1424
  /**
1371
1425
  * opacity of highlight annotation
1372
1426
  */
@@ -1608,19 +1662,23 @@ export interface PdfSquigglyAnnoObject extends PdfAnnotationObjectBase {
1608
1662
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
1609
1663
  type: PdfAnnotationSubtype.SQUIGGLY;
1610
1664
  /**
1611
- * Text contents of the highlight annotation
1665
+ * Text contents of the squiggly annotation
1612
1666
  */
1613
1667
  contents?: string;
1614
1668
  /**
1615
- * color of strike out annotation
1669
+ * Color of the squiggly markup (preferred over deprecated `color`)
1616
1670
  */
1617
- color: string;
1671
+ strokeColor?: string;
1618
1672
  /**
1619
- * opacity of strike out annotation
1673
+ * @deprecated Use strokeColor instead. Will be removed in next major version.
1674
+ */
1675
+ color?: string;
1676
+ /**
1677
+ * opacity of squiggly annotation
1620
1678
  */
1621
1679
  opacity: number;
1622
1680
  /**
1623
- * quads of highlight area
1681
+ * quads of squiggly area
1624
1682
  */
1625
1683
  segmentRects: Rect[];
1626
1684
  }
@@ -1633,19 +1691,23 @@ export interface PdfUnderlineAnnoObject extends PdfAnnotationObjectBase {
1633
1691
  /** {@inheritDoc PdfAnnotationObjectBase.type} */
1634
1692
  type: PdfAnnotationSubtype.UNDERLINE;
1635
1693
  /**
1636
- * Text contents of the highlight annotation
1694
+ * Text contents of the underline annotation
1637
1695
  */
1638
1696
  contents?: string;
1639
1697
  /**
1640
- * color of strike out annotation
1698
+ * Color of the underline markup (preferred over deprecated `color`)
1641
1699
  */
1642
- color: string;
1700
+ strokeColor?: string;
1643
1701
  /**
1644
- * opacity of strike out annotation
1702
+ * @deprecated Use strokeColor instead. Will be removed in next major version.
1703
+ */
1704
+ color?: string;
1705
+ /**
1706
+ * opacity of underline annotation
1645
1707
  */
1646
1708
  opacity: number;
1647
1709
  /**
1648
- * quads of highlight area
1710
+ * quads of underline area
1649
1711
  */
1650
1712
  segmentRects: Rect[];
1651
1713
  }
@@ -1662,15 +1724,19 @@ export interface PdfStrikeOutAnnoObject extends PdfAnnotationObjectBase {
1662
1724
  */
1663
1725
  contents?: string;
1664
1726
  /**
1665
- * color of strike out annotation
1727
+ * Color of the strikeout markup (preferred over deprecated `color`)
1666
1728
  */
1667
- color: string;
1729
+ strokeColor?: string;
1730
+ /**
1731
+ * @deprecated Use strokeColor instead. Will be removed in next major version.
1732
+ */
1733
+ color?: string;
1668
1734
  /**
1669
1735
  * opacity of strike out annotation
1670
1736
  */
1671
1737
  opacity: number;
1672
1738
  /**
1673
- * quads of highlight area
1739
+ * quads of strikeout area
1674
1740
  */
1675
1741
  segmentRects: Rect[];
1676
1742
  }
@@ -1720,7 +1786,11 @@ export interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
1720
1786
  */
1721
1787
  opacity: number;
1722
1788
  /**
1723
- * Background color of the free text annotation
1789
+ * Background/fill color of the free text annotation (matches shape convention)
1790
+ */
1791
+ color?: string;
1792
+ /**
1793
+ * @deprecated Use color instead. Will be removed in next major version.
1724
1794
  */
1725
1795
  backgroundColor?: string;
1726
1796
  /**
@@ -1732,12 +1802,69 @@ export interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
1732
1802
  */
1733
1803
  richContent?: string;
1734
1804
  }
1805
+ /**
1806
+ * Pdf redact annotation
1807
+ *
1808
+ * @public
1809
+ */
1810
+ export interface PdfRedactAnnoObject extends PdfAnnotationObjectBase {
1811
+ /** {@inheritDoc PdfAnnotationObjectBase.type} */
1812
+ type: PdfAnnotationSubtype.REDACT;
1813
+ /**
1814
+ * Text contents of the redact annotation
1815
+ */
1816
+ contents?: string;
1817
+ /**
1818
+ * Quads defining the redaction areas (like markup annotations)
1819
+ */
1820
+ segmentRects: Rect[];
1821
+ /**
1822
+ * Interior color - the preview color shown BEFORE redaction is applied
1823
+ */
1824
+ color?: string;
1825
+ /**
1826
+ * Overlay color - the fill color shown AFTER redaction is applied
1827
+ */
1828
+ overlayColor?: string;
1829
+ /**
1830
+ * Stroke/border color of the redaction box
1831
+ */
1832
+ strokeColor?: string;
1833
+ /**
1834
+ * Opacity of the redact annotation
1835
+ */
1836
+ opacity?: number;
1837
+ /**
1838
+ * Text displayed on the redacted area after applying the redaction
1839
+ */
1840
+ overlayText?: string;
1841
+ /**
1842
+ * Whether the overlay text repeats to fill the redaction area
1843
+ */
1844
+ overlayTextRepeat?: boolean;
1845
+ /**
1846
+ * Font family for the overlay text
1847
+ */
1848
+ fontFamily?: PdfStandardFont;
1849
+ /**
1850
+ * Font size for the overlay text
1851
+ */
1852
+ fontSize?: number;
1853
+ /**
1854
+ * Font color for the overlay text
1855
+ */
1856
+ fontColor?: string;
1857
+ /**
1858
+ * Text alignment for the overlay text
1859
+ */
1860
+ textAlign?: PdfTextAlignment;
1861
+ }
1735
1862
  /**
1736
1863
  * All annotation that support
1737
1864
  *
1738
1865
  * @public
1739
1866
  */
1740
- export type PdfSupportedAnnoObject = PdfInkAnnoObject | PdfTextAnnoObject | PdfLinkAnnoObject | PdfPolygonAnnoObject | PdfPolylineAnnoObject | PdfHighlightAnnoObject | PdfLineAnnoObject | PdfWidgetAnnoObject | PdfFileAttachmentAnnoObject | PdfStampAnnoObject | PdfSquareAnnoObject | PdfCircleAnnoObject | PdfSquigglyAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfCaretAnnoObject | PdfFreeTextAnnoObject;
1867
+ export type PdfSupportedAnnoObject = PdfInkAnnoObject | PdfTextAnnoObject | PdfLinkAnnoObject | PdfPolygonAnnoObject | PdfPolylineAnnoObject | PdfHighlightAnnoObject | PdfLineAnnoObject | PdfWidgetAnnoObject | PdfFileAttachmentAnnoObject | PdfStampAnnoObject | PdfSquareAnnoObject | PdfCircleAnnoObject | PdfSquigglyAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfCaretAnnoObject | PdfFreeTextAnnoObject | PdfRedactAnnoObject;
1741
1868
  /**
1742
1869
  * Pdf annotation that does not support
1743
1870
  *
@@ -2624,6 +2751,29 @@ export interface PdfEngine<T = Blob> {
2624
2751
  * @returns task contains the result
2625
2752
  */
2626
2753
  redactTextInRects: (doc: PdfDocumentObject, page: PdfPageObject, rects: Rect[], options?: PdfRedactTextOptions) => PdfTask<boolean>;
2754
+ /**
2755
+ * Apply a single REDACT annotation - removes content, flattens RO overlay, deletes annotation.
2756
+ * @param doc - pdf document
2757
+ * @param page - pdf page
2758
+ * @param annotation - the REDACT annotation to apply
2759
+ * @returns task contains the result
2760
+ */
2761
+ applyRedaction: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
2762
+ /**
2763
+ * Apply all REDACT annotations on a page - removes content, flattens overlays, deletes annotations.
2764
+ * @param doc - pdf document
2765
+ * @param page - pdf page
2766
+ * @returns task contains the result
2767
+ */
2768
+ applyAllRedactions: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<boolean>;
2769
+ /**
2770
+ * Flatten an annotation's appearance (AP/N) to page content and remove the annotation.
2771
+ * @param doc - pdf document
2772
+ * @param page - pdf page
2773
+ * @param annotation - the annotation to flatten
2774
+ * @returns task contains the result
2775
+ */
2776
+ flattenAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
2627
2777
  /**
2628
2778
  * Extract text on specified pdf pages
2629
2779
  * @param doc - pdf document
@@ -2784,6 +2934,9 @@ export interface IPdfiumExecutor {
2784
2934
  extractPages(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<ArrayBuffer>;
2785
2935
  extractText(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<string>;
2786
2936
  redactTextInRects(doc: PdfDocumentObject, page: PdfPageObject, rects: Rect[], options?: PdfRedactTextOptions): PdfTask<boolean>;
2937
+ applyRedaction(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
2938
+ applyAllRedactions(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<boolean>;
2939
+ flattenAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
2787
2940
  getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): PdfTask<string[]>;
2788
2941
  getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfGlyphObject[]>;
2789
2942
  getPageGeometry(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfPageGeometry>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/models",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
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",