1
votes

I'm developing a SharePoint web part which is basically a form connected to an SPO list. In the form I'm thinking of using an attachment field for the user to attach a word or pdf doc. Is there anything out there that I could use in the code to display the contents of this attachment within the form or somehow print out the contents of the document without having to open the document?

1

1 Answers

3
votes

You can use the SharePoint Online Office Web Apps by appending text to the document's URL.

https://yourDomain/sites/yourSite/Lists/Tasks/Attachments/1/AdventureWorksBikes.xlsx?web=1

or by using a direct path to document viewer page:

https://yourDomain/sites/yourSite/sites/yourSite/_layouts/15/Doc.aspx?sourcedoc=/sites/yourSite/Lists/Tasks/Attachments/1/AdventureWorksBikes.xlsx&action=default&mobileredirect=true

You could put the above in an IFRAME if you want to display it in your existing page.