phonegap Generate and download pdf or save it in sd card ?

952 views
Skip to first unread message

adeelah...@gmail.com

unread,
Apr 20, 2013, 3:43:12 AM4/20/13
to phon...@googlegroups.com
hi Simon,

I am new to phonegap and android I am developing a application of Android Uisng phonegap html 5 and javascript with jquerymobile. This application is not web application it will install in the device.
I am developing a application of Android Uisng phonegap html 5 and javascript with jquerymobile. This application is not web application it will install in the device. I have some reports in this application i want to convert html content of the reports in the pdf and download it in local device. I have tried jspdf plugin but it doesnot works fine can any body help me in this regard i am stuck with this issue since last week i will be very thankfull to you people. kindly help me and sory for my bad english if you found any mistakes in writing the problem. :-)
this is query i have posted on serveral forums

the code i am using is as under

i have two functions one to open child browser as given below

  function childbrowser()
         {
          alert("childbrowser");
          alert(window.location.href);
          window.plugins.childBrowser.showWebPage(window.location.href, { showLocationBar: true });
         }

and other to download the generated pdf..


  function downloadpdf()
         {
          
          try {
              //  var doc = new jsPDF();
              
              var htmlcontent="<!doctype><html><head><title>jsPDF</title></head>"+$('#mybody').html()+"</html>";
              
               var pdf = new jsPDF('p','in','letter')
               ,source = htmlcontent;
       
        specialElementHandlers = {
        // el ement with id of "bypass" - jQuery style selector
        '#bypassme': function(element, renderer){
        // true = "handled elsewhere, bypass text extraction"
        return true
        }
        }
               //  doc.text(20, 20, 'This PDF has a title, subject, author, keywords and a crea');
              //  alert(doc.output());
              pdf.fromHTML(
      source // HTML string or DOM elem ref.
      , 0.5 // x coord
      , 0.5 // y coord
      , {
       'width':7.5 // max width of content on PDF
      ,'elementHandlers': specialElementHandlers
      }
      )
     
      alert(window.location.href);
             pdf.addPage();
         
             // var out= pdf.output('datauri');
         //  navigator.saveAs(htmlcontent, 'mmmmmmm.pdf');
         
         
           pdf.save('adeel.pdf');
          // alert("out   "+out); 
           
           // var out = jsPDF.output();
         //  var url = 'data:application/pdf;base64,' + btoa(out);
          //  document.location.href = url;
     
         //  pdf.save('adeel.pdf');
     
     
          } catch (e) {
              return e.message;
          }
          return ""; 
          
         }
         

it works fine in the browser of my system but not in the virtual tablet device in which application is install it gives the following error in the green .


04-20 12:26:22.515: I/SqliteDatabaseCpp(759): sqlite returned: error code = 14, msg = cannot open file at line 27701 of [8609a15dfa], db=/data/data/com.example.energy_e360/databases/webview.db

04-20 12:26:22.465: I/SqliteDatabaseCpp(759): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/CachedGeoposition.db, db=/data/data/com.example.energy_e360/databases/webview.db


any help will be appreciated.

raghu datta

unread,
Oct 18, 2016, 6:00:31 PM10/18/16
to phonegap
HI 

HAve you got any solution?

Even i am stuck in same issue please help

Kerri Shotts

unread,
Oct 19, 2016, 9:02:01 AM10/19/16
to phonegap
Don't resurrect old threads. Post a new question with the information requested in the welcome text for this group.

On Tuesday, October 18, 2016 at 5:00:31 PM UTC-5, raghu datta wrote:
...
Reply all
Reply to author
Forward
0 new messages