Pdf in Desktop application
Is there an easy way to display a (local) pdf within an titanium application?
I tried it via iframe providing the file path as file:///…
That did not work.
Any suggestions?
Cheers
Rob
4 Answers
-
Accepted Answer
I don't think there is a clear strategy in Titanium at the moment how it handles other MIME types than HTML. I had a discussion in the old forums about this topic. For me, sometimes PDFs get displayed via the Acrobat plugin, sometimes I see just the binary data of the PDF as plaintext.
A reliable solution is to call the system's standard viewer via the Process API. Under Linux you can call 'xdg-open' and on OS X just 'open' and give the PDF as argument. This works well for me (I still have to figure out how to do it on Windows but I'm sure there is a system call as well)
-
function openpdf(docpath){ var pdfprocess=Titanium.Process.createProcess({ args:['cmd','/C',docpath], }); //alert("p"); pdfprocess.launch(); }
where docpath is something like "c:\dir name\dir\filename.pdf"
-
Adding
‹embed src=“filename.pdf” width=“100%” height=“100%”›
in the HTML works for me.Though I'm getting lots of "unlockFocus called too many time." errors in OSX now…
-
How about building a 3rd party PDF viewer with the help of some manual toolkits to help dispaly and read PDF files? I am not so sure about it. But I hope you success. Good luck.
Best regrads,
Arron