Page 3 of 6

How to do print currnt page when click on Print button.

Posted: Sun Apr 20, 2014 3:19 pm
by Asif

Hi Igor,
I have debugged the application by following the instructions provided in the link you provided,

I am getting following error : Image


How to do print currnt page when click on Print button.

Posted: Sun Apr 20, 2014 8:41 pm
by Igor

Hi,

Can you show us JS code from the ipadscreen1.js file lines 360-370 ?


How to do print currnt page when click on Print button.

Posted: Mon Apr 21, 2014 8:41 am
by Asif

Hi Igor,
Given below is the code you have asked for :
code
$(document).off("click", '#ipadscreen1_mobilecontainer2 [name="mobilebutton_80"]').on({
click: function() {
if (!$(this).attr('disabled')) { // Get HTML string
var page = document.body.innerHTML;

Code: Select all

                     // Pass the HTML 
                     window.plugin.printer.print(page); 

                 } 
             }, 
         }, '#ipadscreen1_mobilecontainer2 [name="mobilebutton_80"]'); 

/code


How to do print currnt page when click on Print button.

Posted: Tue Apr 22, 2014 1:09 am
by Illya Stepanov

Hi Asif,

Where did you tested your app? Is it .apk or other way?

You can test plugins only when compile app in .apk and install it into device.

http://prntscr.com/3c86s7/direct

In your screenshoot, we can see an error of window.plugin. - there is no object.

So, that means only two things: whether you tested it not as the native app (with installed plugin) or you didn't install plugin correctly.

Please add this following code on the "page show" event to understand whether a plugin was successfully integrated:
precode
alert("window.plugin = " + window.plugin);
alert("window.plugin.printer" + window.plugin.printer);/code/pre
Regards.


How to do print currnt page when click on Print button.

Posted: Wed Apr 23, 2014 1:43 pm
by Asif

Hi lllya,

I am testing the app using .apk file only on the device.

For first alert, i am getting "window.plugin = undefined"
and for second alert, i m getting "Uncaught TypeError: Cannot read property 'printer' of undefined "


How to do print currnt page when click on Print button.

Posted: Thu Apr 24, 2014 1:26 am
by Illya Stepanov

Hi Asif.

precode
"window.plugin = undefined"/code/pre
It means: plugin did't inited correctly.

Please share your app with us.

Regards.


How to do print currnt page when click on Print button.

Posted: Thu Apr 24, 2014 6:15 am
by Asif

Hi lllya,
I have shared my app with 'a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a'. Name of the app is 'POS'


How to do print currnt page when click on Print button.

Posted: Fri Apr 25, 2014 1:34 pm
by Nikita

Hi,

In Printer.java change row
packet de.appplant.cordova.plugin.printer;
on
packet com.phonegap.plugins.printer;

And rename folder "de.appplant.cordova.plugin.printer" on "com.phonegap.plugins.printer" (folder contains www/printer.js)

In file cordova_plugins.js change rows that include plugin on next rows
{
"file": "plugins\com.phonegap.plugins.printer\www\printer.js",
"id": "com.phonegap.plugins.Printer",
"clobbers": [
"Printer"
]
}

And try create event on any button click with such code
alert("window.plugin = " + window.plugin);


How to do print currnt page when click on Print button.

Posted: Sat Apr 26, 2014 9:23 am
by Asif

Hi Nikita,
I have made changes which you have mentioned,but still i m getting same error

code
window.plugin= undefined
/code


How to do print currnt page when click on Print button.

Posted: Mon Apr 28, 2014 7:44 am
by Kateryna Grynko

Hi Asif,

You have included plug-in correctly. Try using this function:prewindow.plugin.print (...)/pre