The highlighted text helps the reader quickly and efficiently get the critical information of the article. In the PDF file, the text highlighting of different text, keywords, sentences and so on, can make the reader effectively distinguish the meaning of different highlighted color text in the process of reading. In the following example, I use free spire.pdf for. NET to operate (https://www.e-iceblue.cn/Downloads/Free-Spire-Doc-NET.html), you can refer to the following steps:
The original file is as follows:
650) this.width=650; "src=" Https://s5.51cto.com/oss/201710/19/54e9f6e420d1ec21acaa6e975e768aae.png "title=" 1.png " alt= "54e9f6e420d1ec21acaa6e975e768aae.png"/>
Step One: Initialize and load a PDF Document Instance
Pdfdocument PDF = newpdfdocument (@ "c:\users\administrator\desktop\c#.pdf");
Step Two: Call the FindText () method to find the specified text "C #"
pdftextfind[] Result1 = null;result1= PDF. Pages[0]. FindText ("C #"). Finds;
step three; iterate through all the search results, highlighting the text in blue " C # "
foreach (Pdftextfind Find in Result1) {find. Applyhighlight (Color.Blue); }
Step four: Call the FindText () method to find the specified text "Microsoft"
pdftextfind[] result2 = null;result2= PDF. Pages[0]. FindText ("Microsoft"). Finds;
Step Five: Iterate through all search results, highlighting the text in purple " Microsoft "
foreach (Pdftextfind Find in result2) {find. Applyhighlight (Color.purple)}
Step Six: Save the document
Pdf. SaveToFile ("Result.pdf", fileformat.pdf);
When you are done, debug and run the project, generating the document (viewable in folder Bin>debug in the project) such as:
650) this.width=650; "src=" Https://s5.51cto.com/oss/201710/19/660f41d0013035cc7f13359f2fb7c6f3.png "title=" 1.png " alt= "660f41d0013035cc7f13359f2fb7c6f3.png"/>
the above is about C # in the PDF Chinese text Search and highlight the operation, I hope you have some help, thank you for reading!
This article is from the "Mochou" blog, make sure to keep this source http://miayo.blog.51cto.com/13270370/1974269
How C # Highlights text in a PDF in a different color