MCPcopy Create free account
hub / github.com/LibPDF-js/core / addTextMarkupAnnotation

Method addTextMarkupAnnotation

src/api/pdf-page.ts:2007–2034  ·  view source on GitHub ↗

* Add a text markup annotation (internal helper).

(
    subtype: "Highlight" | "Underline" | "StrikeOut" | "Squiggly",
    options: TextMarkupAnnotationOptions,
  )

Source from the content-addressed store, hash-verified

2005 * Add a text markup annotation (internal helper).
2006 */
2007 private addTextMarkupAnnotation(
2008 subtype: "Highlight" | "Underline" | "StrikeOut" | "Squiggly",
2009 options: TextMarkupAnnotationOptions,
2010 ): PDFAnnotation {
2011 // Use the static create method on the appropriate class
2012 let annotDict: PdfDict;
2013
2014 switch (subtype) {
2015 case "Highlight":
2016 annotDict = PDFHighlightAnnotation.create(options);
2017 break;
2018 case "Underline":
2019 annotDict = PDFUnderlineAnnotation.create(options);
2020 break;
2021 case "StrikeOut":
2022 annotDict = PDFStrikeOutAnnotation.create(options);
2023 break;
2024 case "Squiggly":
2025 annotDict = PDFSquigglyAnnotation.create(options);
2026 break;
2027 }
2028
2029 // Register and add to page
2030 const annotRef = this.ctx.register(annotDict);
2031 this.addAnnotationRef(annotRef);
2032
2033 return createAnnotation(annotDict, annotRef, this.ctx.registry);
2034 }
2035
2036 /**
2037 * Add a link annotation.

Callers 4

addSquigglyAnnotationMethod · 0.95

Calls 4

addAnnotationRefMethod · 0.95
createAnnotationFunction · 0.90
createMethod · 0.65
registerMethod · 0.45

Tested by

no test coverage detected