本文介绍了使用C#突出显示PDF格式的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码来从pdf文件中提取文字,
Hi,
I am using below code to exract text from pdf file,
public string ReadPdfFile()
{
string strText = string.Empty;
try
{
PdfReader reader = new PdfReader(@"\\FilePath");
for (int page = 1; page <= reader.NumberOfPages; page++)
{
ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
String s = PdfTextExtractor.GetTextFromPage(reader, page, its);
s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
strText = strText + s;
}
reader.Close();
}
catch (Exception ex)
{
}
return strText;
}
此代码返回PDF文件的一页中的所有文本,我需要在黄色的PDF页面上突出显示我选择的任何单词。
任何想法怎么做?
问候,
凯恩
This code returns all the text from one page of the PDF file, I need to highlight any word of my choice on that PDF page with yellow colour.
Any ideas how to do that?
Regards,
Kane
推荐答案
这篇关于使用C#突出显示PDF格式的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!