0

An API call returns files that can be text or pdf file or doc. What is the best way to present these documents to the user? Is there any npm module that can work with many file formats (.pdf, .text, .doc)? Thanks in advance

3
  • 1
    i recommend you start from this one github.com/plangrid/react-file-viewer Commented Jun 7, 2020 at 5:00
  • 1
    this does not work it crashes my app Commented Jun 7, 2020 at 6:09
  • 1
    Which type of files you have docx/xslx or doc/xsl? It's important because of react-file-viewer supported next file formats: png, jpeg, gif, bmp, including 360-degree images, pdf, csv, xslx, docx, mp4, webm, mp3 Commented Jun 7, 2020 at 7:23

1 Answer 1

1

If the api you mentioned gives you files in the form of a downloadable link, then you can use Google Docs's Embedded viewer Use it as follows

<iframe src="https://docs.google.com/gview?url=[path_to_file]embedded=truestyle="width:600px; height:500px;" frameborder="0"/>

Replace path_to_file with the link you get from the api. It supports the file formats you mentioned in the question

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.