Document Viewer for pdf and txt files
In this article we are going to use document viewer to view .pdf/.txt files in the browser. Many applications required to show some documents to the user or user would like to see some documents uploaded by them.
The document viewer which has been used in this code is open-source and is available for download in Git. You can download ViewerJS from this site.
Now let us see an example of ViewerJS.
Once ViewerJS has been downloaded, Include that inside the project.
<html> <head> <title>Document Viewer</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> Lets view the Text File: <a href="ViewerJS/Myfile.txt">Text Document</a><br><br> Lets view the PDF File: <a href="ViewerJS/myfile.pdf">PDF Document</a> </body> </html>
Note: Please make sure .txt/.pdf files are stored inside ViewerJS folder