Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

how to create pdf from image/photo in titanium using jsPDF library

$
0
0
I am creating pdf using jsPDF Library.but when i upload it to the server the pdf seen blur on windows but perfectly working on Mac machine. I am using titanium sdk 3.2.3. so how can i solve this problem? I am pasting my code here. //getting image from camera image = event.media; //writing image to file f f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'camera_photo.png'); if (f != null) { f.deleteFile(); } f.write(image); //Include jsPDF var _jsPDF = require('./jsPDFMod/TiJSPDF'); var _isAndroid = Ti.Platform.osname === 'android'; var _tempFile = null; //Creating object and setting properties var doc = new _jsPDF(); doc.setProperties({ title : 'Title', subject : 'This is the company', author : 'e-biz', keywords : 'one, two, three', creator : 'Someone' }); //getting image and showing in imageview var imgSample1 = Titanium.Filesystem.applicationDataDirectory + 'camera_photo.png'; anImageView.image = imgSample1; //calling to the function doc.addImage(imgSample1, 'JPEG', 0, 0, 100, 100); //saving _tempFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'amoldemo1.pdf'); doc.save(_tempFile); //reading temp file var blob = _tempFile.read(); //sending to the server var xhr = Titanium.Network.createHTTPClient(); xhr.setTimeout(20000); xhr.onload = function(e) { // this is where you would process the returned object. alert(this.responseText); if (this.responseText != null) { // Do something with the object } else { // Webservice returned nothing alert(e); } }; xhr.onerror = function(e) { // This is where you would catch any errors thrown from calling the webservice. // e.error holds the error message alert(e.error); //alert('Somthing went wrong try again later'); }; xhr.open('POST', 'http://192.168.10.66/imedicus/webservice_file_upload.php'); xhr.send({ //patient_number : '209', patient_number : '12791', //file : encodedFile file : blob, });

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>