
PdfTextMarkupAnnotation annotation = new PdfTextMarkupAnnotation("Adminstrator", "Text Markup Annotation", markupText, ptf.Position, new PdfTrueTypeFont(font)) Īnnotation.Border = new PdfAnnotationBorder(0.75f) Īnnotation.TextMarkupColor = Color.Yellow ĭoc.SaveToFile("Annotation.pdf", FileFormat. PdfTextFind ptf =page.FindText("Highlight text").Finds Locate the text that you want to markup Highlight selected text PdfTextFind results = ("Hello World").Finds And it allows to highlight the selected text with custom color or to add markup annotation to specific range of text.

HIGHLIGHT PDF PDF
It supports to load a Pdf file from byte array as well as from a folder in disk. Spire.PDF is a good alternative for your requirements. To MSDN Support, feel free to contact think If you have any compliments or complaints This can be beneficial to other community members reading this thread. Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. PdfAnnotation highlight = PdfAnnotation.CreateMarkup(stamper.Writer, rect, null, PdfAnnotation.MARKUP_HIGHLIGHT, quad) NOTE: The order below doesn't appear to match the actual spec but is what Acrobat producesįloat quad = Create an array of quad points based on that rectangle. NOTE: Technically this isn't used but it helps with the quadpoint calculation Using (PdfStamper stamper = new PdfStamper(reader, fs)) Using (FileStream fs = new FileStream(highLightFile, FileMode.Create, FileAccess.Write, FileShare.None)) PdfReader reader = new PdfReader(outputFile) Bind a reader and stamper to our test PDF String highLightFile = Path.Combine(Environment.GetFolderPath(), "Highlighted.pdf") Create a new file from our test file with highlighting Using (PdfWriter w = PdfWriter.GetInstance(doc, fs))ĭoc.Add(new Paragraph("This is a test")) Using (Document doc = new Document(PageSize.LETTER)) Using (FileStream fs = new FileStream(outputFile, FileMode.Create, FileAccess.Write, FileShare.None))

String outputFile = Path.Combine(Environment.GetFolderPath(), "Test.pdf") Private void Form1_Load(object sender, EventArgs e) Once you have the highlight you can set the color using: highlight.Color = BaseColor.YELLOW Īnd then add it to your stamper stamper.AddAnnotation(highlight,1) Open your PDF in Adobe Acrobat Reader DC.
HIGHLIGHT PDF PRO
Although most of the features for editing a PDF in Adobe Reader are available only on the paid Adobe Acrobat Pro DC version, text highlighting can still be done using the Free Adobe Acrobat Reader DC by following the below steps. PdfAnnotation highlight = PdfAnnotation.CreateMarkup(stamper.Writer, rect, null, PdfAnnotation.MARKUP_HIGHLIGHT, quad) Steps to Highlight Text in PDF Using Adobe Acrobat Reader DC. If you want to highlight text in pdf document using an existing PdfStamper called
