NightTom
NightTom

Reputation: 486

Displaying an SP item attachment within a SharePoint web part using spfx

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?

Upvotes: 1

Views: 659

Answers (1)

Mike Smith - MCT
Mike Smith - MCT

Reputation: 1231

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.

Upvotes: 3

Related Questions