Printing variable contents during runtime - Forum

Forum Navigation
You need to log in to create posts and topics.

Printing variable contents during runtime

Is there a way to send to a local wifi printer, the contents of a variable or a txt file?

As far as I know, the only way to send information to the local printer in a pure Web App is printing the whole interface using:

BeginJS
  window.print();
EndJS

So, if you want to print, let's say the content within a container "Container1", you can use something like this:

BeginJS
   var printContents = $('#Container1').html();
   w = window.open();
   w.document.write(printContents);
   w.document.close();
   w.focus();
   w.print();
   w.close();
EndJS

This will copy the content into a new window or tab and print it.
If you are deploying to PhoneGap or NWjs, there will be probably additonal options using specific plugins or JavaScript APIs.

Thanks Luis,  That might do the trick.  I have not checked, but I guess i can apply variables to a formatted container doc and then print that with your script.   I am going to be generating android and ios apps so I will have to see what other tools are available.  If you come across any you think good, let me know.

Don