I need to display PDF preview in WPF control, programmatically search for text in it, highlight found text and be able to copy text. Sounds simple, but I am struggling with different approaches for a week already.
Here what I have considered:
- Find PDF controls for WPF
Most of them just render PDF as images or cost too much. Royalty or subscription fee is not an option. The only suitable control that I found is: http://www.syncfusion.com/products/wpf/pdf-viewer I was even able to do searches programmatically with reflection hacks, but it renders text too blurry (Syncfusion promise to fix this soon) and load pages with a noticeable lag during scrolling.
- Using AcroPDFlib as an ActiveX component
I was not able to make it work with the latest Adobe reader on Windows 10 64-bit. But I don't see methods for search anyway, so I dropped this. Also, it seems that it is not free for commercial use: AcroPDFlib, AxAcroPDFLib commercial use
- Load PDF in WebBrowser control
It works and even allow searches, but it can search only for single words which make this search useless. If I search for "big apple" it highlights all big and apple and also open this search panel that cover the document.
- Send CTRL+F and text to the browser control to trigger search
I have tried to use this library http://inputsimulator.codeplex.com/ But PDF in browser control seems to ignore keystrokes from there or maybe I am doing something wrong. Still considering this option.
- Use pdf.js in browser control
IE7-based control from WPF won't support that, so I need another browser control. And it seems that I also need to start nodejs to make it work. Seems like a too much overhead for this task. And also it is not clear does PDF.js supports search for a phrase or not. But I am still not discarding this option. Does anyone were able to make it work inside WPF?
Any suggestions?