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
-
1i recommend you start from this one github.com/plangrid/react-file-viewerPavel Petrovich– Pavel Petrovich2020-06-07 05:00:53 +00:00Commented Jun 7, 2020 at 5:00
-
1this does not work it crashes my appKritish Bhattarai– Kritish Bhattarai2020-06-07 06:09:34 +00:00Commented Jun 7, 2020 at 6:09
-
1Which 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, mp3Pavel Petrovich– Pavel Petrovich2020-06-07 07:23:56 +00:00Commented Jun 7, 2020 at 7:23
Add a comment
|
1 Answer
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