How to view/open .doc file from sd card inside android app - javascript

I have requirement to view .doc file inside android app, I have gone through many related post but still not clear what to do.
I have tried :
aspose word api for android I got api for creating .doc file but there is not a specific method to view .doc file.
I gone through apache POI but there is i have to write function for render content.
Embedding .doc inside Webview Does not work for local files.
Olivedoc Library is missing.
Please suggest me if there is any library for .doc file same as pdfViewer for PDF.
Thanks.

Look here. AFIK there is no library for rendering such files in android (Correct me if I'm wrong). You have to create an intent to open your file in an external app, as described in the linked question.
If you want to render the new .docx or OpenOffice .odp files, there are various libraries (search on github).
I know this is not what you want to hear, but there does not seem to be any way to do what you want. (BTW, WebView does work for local files, but cannot render .doc files.)

Related

Is there any way to open file in its default application using JavaScript?

I want to open a file in its Windows default application.
Actually, the scenario is as below:
A file is saved in Database and it is shown as a preview in CKEditor
When I double click on that file, it should open in its default application. The file can be a Word or Excel or PDF file
Then the user will edit the file in that default application
And when the user saves that file or closes the document, it should be updated on the server also it should refresh the file preview in CKEditor
I just want to know if there is any way to open the file in its default application.
Things I have tried:
I tried to use the ActiveX object to open the file, but it is not supported in Chrome and Firefox. And anyway, many forums are saying that it is the end of ActiveX era.
Tried to find if there is any CKEditor plugin, but did not find any.
Thank you in advance for your answer.
Short answer: no. Can you imagine the security nightmare if JavaScript was allowed to execute arbitrary binary files on a user's machine?
Your solution is going to be to find a JavaScript library that allows for handling those files, similar to how PDF.js was made for PDFs in-browser.

Use PDF.js offline

Is it possible to use PDF.js without having the website online? I'm trying to do a simple offline website that reads pdf using pdf.js but it won't work without being online.
Anyone could help?
Yes absolutely you can use it offline. Download the latest version here.
Now extract the zip file and put it on a server(use xampp/wamp/lamp or any other localhost) because the worker is not enabled for file:// urls.
To show the pdf files traverse to web/viewer.html from the localhost and it should load its default pdf.
As to the question about how to show your pdf's use: viewer.html?file=relative/path/to/your/pdf
Say for example inside the web folder(the one in which viewer.html is there) of your pdf.js you create a directory say named pdfFiles and in it you add a pdf named say mypdf.pdf in it then to display it use: viewer.html?file=pdfFiles/mypdf.pdf and it will display it.
Look here for more details on how to dynamically assign PDF file paths to the viewer. If you have any other queries let me know. I have used pdf.js offline and it works wonderfully on almost all the browsers I know.

Render pdf with Rails

In my project, I want to somehow display a pdf file on the page. For this, I am trying to use the <object> tag. So far, so good, since the pdf lives in the /public folder in my Rails app.
The problem is that now I want the user to be able to display a pdf that is on his pc. I tried using Javascript to alter the <object> tag, but that does not work since Rails generates a new GET request to get the file, and the file is not on the server. Any ideas of how I can solve this?
I have tried using PDF.js, but it does not integrate well in the assets pipeline. Also, I would have to customize and hack the code to add some other functionalities, so PDF.js is kinda off the table (at least for now).
You can use the wicked_pdf gem to generate pdf then use Google PDF viewer for displaying it

How to secure PDF files from download but allow it to View?

I want to integrate some kind of web based PDF viewer so that user can not download the PDF files but they can View them. This is for securing the PDF files from downloads. Something like scribd.com
See example here : ref link
I used FlexPaper: flexpaper.devaldi.com
This compile PDF in SWF, so is more protected.
I think you need something like pdftohtml.
It is a tool based on the Xpdf package which translates PDF documents into HTML format.
You could use Flexpaper, too, but it's free of charge only for open source projects...

Viewing uploaded .PDF or .DOC as pictures without converting

Recently, I am working on a feature which the user could upload files like .pdf or .doc and then viewing them as pics on the web page. I am wondering is there a way that I can do that without actually converting them to .jpg or .png by a third party software on the server? Is it possible to implement this feature only us js,jquery and django?
Not sure about .doc you would need to go and convert that into PDF. You can show PDFs by using created by Mozilla
pdf.js

Categories