Unanswered: Document readers?
I need the ability to view documents like .docx and .pdf either within a Space app or invoked into some external iOS app, while offline.
I am storing the documents in base64 in the space SecureFiles store, which was fairly easy to setup and works quite well with images so far. However, I have no idea how to open a docx or pdf in the same manner.
I tried window.open("data:application/pdf;base64,...") to open a browser window but in Space it always results in replacing the app in the same window. I can get back to the app with the back arrow but it's clearly not a useful solution.
I tried the Ext.ux.panel.PDF extension but it doesn't work, it won't accept binary or string data and only works for pdfs anyways.
I read up on Invoke but can't seem to find any info about invoking a document reader on the device. Does such an invoke command exist? If not, any helpful suggestions would be greatly appreciated. Thank you!
Just an update to my problem.
I got Ext.ux.panel.PDF to load without errors but it will always render PDFs as a blank canvas in Space. It works as expected in Chrome on my desktop machine tho, so maybe Space doesn't support all the canvas features that PDFJS needs?
I tried using an iFrame to contain the document and load it in whatever native viewer Space uses. This resulted in the PDF showing up very nicely in the page, but it can't be panned or scrolled. I was reading around and learned that iOS/Safari can't pan or scroll iframes, so I assume Space is based on the same browser engine (webkit?) and has the same limitations.
I find it hard to believe that viewing a document, especially something as common as a PDF, is so difficult. /sigh
Sencha - IO Dev Team
In the case of document viewing we are currently limited by the capabilities of the platform space is running on. On both iOS and android we use the native document viewer to view non-html file types. In the case of iOS there are a large umber of file types it supports including PDF. On android however it only supports images.
We are working now to provide a custom file viewer on Android and Windows phone, but unfortunately we don't have a precise delivery date on those features.
As we are working on integrating a custom file viewer on android we haven't tested PDF.js. We will investigate and let you know what we can get working.
Thanks for the update Jason.
In regards to iOS, I think I need to clarify some of the problems, because it's not just that I can't display a PDF. I can display a PDF in various ways, but none of them work as expected.
- I can use window.open("data:application/pdf;base64,"+fileData, "_blank") to open the viewer with the file displayed correctly and scrollable. BUT even though I specified "_blank" the file viewer will still replace the app in Space. This requires the user to use the back arrow to get back to the application, which is a completely unsuitable situation.
The expected behaviour is that Space will open the document in a new tab, or in an external native viewer outside the Space application such that the application and the document can both be open at the same time.
- I can use an iframe in a panel in the application. The iFrame will load the document in the native viewer just fine. BUT in Safari/Webkit based browsers on iOS the iFrame element is not scrollable and therefore the document cannot be navigated or zoomed.
This is apparently a limitation of Safari/Webkit on iOS so I don't expect you to have a solution to this, though the use of an iFrame would be my ideal way of showing a document so it's really a pain for me personally.
- I cannot use Ext.ux.panel.PDF because it will not render a PDF correctly. Also, I need a viewer that displays .docx files, and this solution cannot do that even if it worked.
I also want to make note that on Android there is no problem. When I use window.open() or an iframe in Android the OS asks the user if they want to open it in a viewer program, that program will then be opened outside Space and thus allow the user to both view the file and use the Space application at the same time. This is not the ideal solution but it is sufficient.
My Ideal Solution is: To have an iframe in a Panel in my Space application that will display a docx/pdf file inline in the panel and be scrollable/zoomable.