Hi I trying highlight the text in a document using itext annotation. I not able to see the highlighted text in the generated document. Can anyone help me on the same Please find the code below. Also i need to highlight text in different colors. when user click out the highlighted area it need to pop up the PDF Comment/sticky note.
using (PdfReader pdfReader = new PdfReader(@"C:\test\sample2.pdf")) using (FileStream fileOut = new FileStream(@"C:\test\test4.pdf", FileMode.Create, FileAccess.Write)) using (PdfStamper stamp = new PdfStamper(pdfReader, fileOut)) { LocationTextExtractionStrategyEx strategy = new LocationTextExtractionStrategyEx(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, 1, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); foreach (var strat in ((LocationTextExtractionStrategyEx)(strategy)).TextLocationInfo) { PdfAnnotation annotate = new PdfAnnotation(stamp.Writer, new iTextSharp.text.Rectangle(strat.TopLeft[0], strat.BottomRight[1], (strat.TopLeft[0] + 5), (strat.BottomRight[1] - 5))); stamp.AddAnnotation(annotate, 1); } } Regards Barath -- View this message in context: http://itext-general.2136553.n4.nabble.com/How-to-highlight-the-text-in-different-colors-tp4659778.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php