SharePoint: can documents be intercepted / modified before they are returned to the client?

I would like SharePoint to behave as it is, but before returning documents to users, I would like the option to intercept the document and make custom additions / changes.

So basically: 1) Can you even customize the code responsible for "opening" files in SharePoint? 2. If yes, can you do it based on a specific user (for example, use the default code for everyone except a certain class of users) 3) Assuming 1 and 2, you can intercept any file that needs to be returned, and make changes to it (maybe even replacing it with another file)?

(I would rather not do this at the IIS level)

Thanks Rhett

+2


source to share


5 answers


I think what you need to do here is an HttpHandler for documents (e.g. Word files - doc / docx). Here's a link that might help. Also, this link gives details on how to create HttpHandlers. You probably need to add the following to the web.config file for your site:



I'm not too sure how to hook up a handler to work with your documents, as I don't know what file extensions are, but you get the idea.

+1


source


What do you mean by "opening a file"? Viewing a list item or opening the document itself?

Either way, you can edit the list forms using SharePoint Designer. Or you can create your code for this list and do whatever you want with the OnLoad event or some javascript files with loading link attachments.

Or, in your case, if you want to tag your document, you can create a code-back ( practical example here ), override the OnLoad event (when the form is opened), access those documents, and set options.



And on OnUnload you could change the document again to revert back the changes.

What if multiple users want to access the same document? So, you could hide the original document with javascript and display a copy prepared for that user and OnUnload discard it.

However, it will only work when accessing documents from the Internet, not Outlook.

0


source


Create a function that will add SPItemEventReceiver to the library and override ItemUploded. Or use the tool to add events to the librari.

0


source


Can I use a custom page, upload a document and process it before sending it to the client?

So, to make the question more interesting to me, "How do I make all relevant links a link to this redirect page rather than directly to the document?"

Which, of course, may not be possible, especially in the case of working with documents via WebDAV

0


source


HTTPHandler is the only place in the IIS / Asp.Net / SharePoint stack where you have the ability to modify the documents that are sent to the user. As far as this, outside of SharePoint, is actually not the case if you think HTTPHandlers are part of Asp.Net and SharePoint is an Asp.Net application.

If you really wanted to, you can still package and deploy your code as a SharePoint solution and even activate the web.config file activation feature to activate the handler.

0


source







All Articles