javascript - How to open a local PDF in a Windows 8/Cordova app? -


i have ios app built i've been tasked port on windows 8 use on windows tablet. app downloads files dropbox, gets stored in local folder. can see of works fine. able reference images using ms-appdata:///local/" + filename in src of img tag, , i'm able play mp4s same folder using html5 video tags.

my problem is, ios version, using cordova's inappbrowser open local pdfs on windows 8 version, doesn't work.

i using following code (filename equals [1]casestudy-ac_en_04.pdf , exist on file system):

 var ref = window.open("ms-appdata:///local/" + filename, '_blank', 'location=no'); 

and following error in visual studio when run simulator

apphost9607: app can't launch uri @ ms-appdata:///local/[1]casestudy-ac_en_04.pdf because of error: -2147024846. 

i've tried switching winjs coding methods, tried loading pdf in iframe nothing work. don't mind kicking user out internet explorer if must... need way user see these local pdfs. permissions issue? have config.xml file , not app manifest file, perhaps i'm missing setting?

does have experience this?

in case else has issue. able wanted winjs code (make sure include winjs framework file)

//this filename, can skip step filenames downloaded files encoded. filename = decodeuricomponent(filename);  //get local folder contains downloaded files var applicationdata = windows.storage.applicationdata.current; var localfolder = applicationdata.localfolder;  //grab file , return promise localfolder.getfileasync(filename) .then(function(file) {      //launch file - command let os use it's default pdf reader - win 8 app 'reader' works great.      windows.system.launcher.launchfileasync(file); });     

that's it.

@matthew corway works fine. but, need aditional attention when file within subfolder follow exemple:

var fullpath = "\foldername\filename.pdf"


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -