I'm converting an HTML text file to a PDF using LoadFromHTML() and it works great. But the PDF is not searchable using PdfTextFind. Is it possible to convert an HTML file to a PDF using Spire.PDF so that the resulting PDF can be searched for text?
Here's the code for making the PDF:
string htmlString = File.ReadAllText(fileName);
PdfDocument doc = new PdfDocument();
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
PdfPageSettings setting = new PdfPageSettings();
setting.Size = PdfPageSize.Letter;
Thread thread = new Thread(() => { doc.LoadFromHTML(htmlString, false, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
doc.SaveToFile(newFileName, FileFormat.PDF);
And for searching (which returns nothing):
PdfDocument doc = new PdfDocument(fileName);
PdfTextFind[] results = null;
results = doc.Pages[0].FindText(searchText).Finds;
foreach (PdfTextFind find in results)
{
find.ApplyHighLight(Color.Green);
}
doc.SaveToFile(newFileName2, FileFormat.PDF);
Thanks for your help!
Nick Solomon