Within SharePoint 2013, what is the easiest way to determine if a document (i.e. a PDF) is linked to a page or not? I'm in SiteCollectionDocuments library and have to go through 1000 documents to determine which ones are actually linked on a page or not. What would be a good method in solving this?
There is no way in SharePoint OOTB to determine whether a document from a SharePoint document library is referred in a SharePoint page or not. The simplest approch which i followed in my project is,
- Create a console application
- In the console application write code to, fetch the Pages and Site pages library in a site
- Loop through all the items present in the pages/sitepages library
- Get the publishing page content of each item in HTML format
- In the HTML content, get the anchor tags and fetch the href property of each tag
- Compare the href of anchor tag and the URL of the document in SP library
- If matches, log it
- You may write code to reccursively check the pages library from all the subsites in a site collection.