So, I’ve posting about some work I’ve been doing with SharePoint Search. Now, to pull it all together – I’ve been trying to do hit highlighting inside Adobe Reader, so if a user clicks on a search result Adobe Reader opens and automatically searches for occurances of the search term. Doing this requires knowing your file extension (so you only process PDFs this way), knowing the query string parameter for what is being searched for, and that you can pass parameters into Acrobat Reader. I’m not going to go too much into that last part, but you can find documentation about this on Adobe’s website (pdf).
So, what we want to do is for each search result:
- see if it is a PDF
- if it is, pass the search phrase in the url
Um, I guess I’ll skip to the code:
You can get this as a text file here.
So, what does this show? Firstly, you can see that the query string is being passed into our Search Core Results web part, as described previously. We’re also selecting the FileExtension column, also as described previously. Our XSL looks to see if the extension is PDF, and if so it emits the url to the item plus:
These bits are highlighted in yellow. Otherwise, we just output the link. (Note: this page doesn’t really use a lot of the neat features of your search results XML, like the hit-highlighted title).
So what happens then if a user clicks on this link? I searched for ‘Stupid Ferret’ in the example below…
Tada – our search terms are searched for automatically when we open the PDF!