41338

How to save a pdf file in iPhone memory and make it accessible by pdf file opener applications using

Question:

i am new bie to titanium in my app i need to download and save a pdf file in iOS using titanium and the downloaded file can be accessible by third party pdf viewer applications.any help to achieve this thanks in advance.

Answer1:

1- Make sure your webservice returns a PDF file.

2- Use the FileSystem to manage your files

var xhr = Titanium.Network.createHTTPClient({ onload : function() { var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'file.pdf'); f.write(this.responseData); tmpFile = Ti.Filesystem.createTempFile(); var newPath = tmpFile.nativePath + "." + f.extension(); Ti.API.info("newPath: " + newPath); tmpFile = Ti.Filesystem.getFile(newPath); tmpFile.write(f.read()); }, timeout : 10000 }); xhr.open('GET', 'your webservice'); xhr.send();

Now you use a pdf viewer and open the PDF from the externalStorageDirectory I tested on Android, it works !

Recommend

  • python relative import weirdness
  • Given a date how to get Sunday & Saturday of that week
  • Titanium refreshing TableView with new data
  • React-native, render a button click dynamically
  • XMLHttpRequest for Video Tag?
  • Titanium - Perform Action when user clicks on Android Notification
  • ajax function not going to php codeigniter controller
  • How to call JSON webservice from background in iPhone
  • Using a WebService with Akka Actors and the play framework
  • Android - What should I use to get data from remote db?
  • android with msaccess
  • Ajax call always returning error 500 client side
  • Access PCF DEV from external machine on same network as host
  • Deploying pre-encrypted configuration files to a production environment
  • Accessing local repository in offline mode
  • How to load Q library with Require.js?
  • How to display the images in listview
  • back button function for phonegap windows phone 7
  • Can long-polling be achieved in Restlet by just making the thread sleep?
  • EntLib Way to Bind “Null” Value to Parameter
  • Retaining data after updating application
  • Get the number 18437736874454810627
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Creating PDF from TIFF image using iText
  • Private IP address in reserved subnet range
  • Django model inheritance, filtering models
  • Is it possible to open regedit and navigate to straight to a specific key using process.start?
  • How to use JavaScript to determine whether a file exists in a directory?
  • How to suppress a dialog
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Is possible to count alias result on mysql
  • script to move all files from one location to another location
  • Fill an image in a square container while keeping aspect ratio
  • Rearranging Cells in UITableView Bug & Saving Changes
  • R: gsub and capture
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Benchmarking RAM performance - UWP and C#
  • Error creating VM instance in Google Compute Engine
  • Reading document lines to the user (python)
  • Net Present Value in Excel for Grouped Recurring CF