@embedpdf/models 2.3.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
@@ -1073,7 +1073,8 @@ export declare enum PDF_FORM_FIELD_TYPE {
1073
1073
  }
1074
1074
  export declare enum PdfAnnotationColorType {
1075
1075
  Color = 0,
1076
- InteriorColor = 1
1076
+ InteriorColor = 1,
1077
+ OverlayColor = 2
1077
1078
  }
1078
1079
  /**
1079
1080
  * Border style of pdf annotation
@@ -1801,12 +1802,69 @@ export interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
1801
1802
  */
1802
1803
  richContent?: string;
1803
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
+ }
1804
1862
  /**
1805
1863
  * All annotation that support
1806
1864
  *
1807
1865
  * @public
1808
1866
  */
1809
- 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;
1810
1868
  /**
1811
1869
  * Pdf annotation that does not support
1812
1870
  *
@@ -2693,6 +2751,29 @@ export interface PdfEngine<T = Blob> {
2693
2751
  * @returns task contains the result
2694
2752
  */
2695
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>;
2696
2777
  /**
2697
2778
  * Extract text on specified pdf pages
2698
2779
  * @param doc - pdf document
@@ -2853,6 +2934,9 @@ export interface IPdfiumExecutor {
2853
2934
  extractPages(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<ArrayBuffer>;
2854
2935
  extractText(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<string>;
2855
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>;
2856
2940
  getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): PdfTask<string[]>;
2857
2941
  getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfGlyphObject[]>;
2858
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.3.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",