Giter VIP home page Giter VIP logo

cordova-plugin-bluetooth-printer's People

Contributors

srehanuddin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-bluetooth-printer's Issues

Using on IONIC

I have error like " ionic.bundle.js:26794 Error: [$injector:unpr] Unknown provider: $BTPrinterProvider <- $BTPrinter <- printBt "

anyone can help me how to use it

My Code

.controller('printBt',['$scope', '$BTPrinter' ,function($scope, $BTPrinter) {

$scope.printbtes = function(){
var doc ="tes";
$BTPrinter.connect().then(function(res) {
console.log("success");
console.log(data);
},function(err){
console.log("Error");
console.log(err);
}, "PrinterName")
}

}])

Problem with integrating into Ionic3

Could somebody please let me know, why it's not working with my Ionic project? I just created a test project to test the plugin.

https://github.com/OliverTr54/bletest.git

I did some alerts to figure out, if the function is started or not, but after the first alert - executing the BTPrinter.... I get no other alert anymore, neither on success or error :( What am I doing wrong?

I use Ionic 3:

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.8
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : none
    Ionic Framework                 : ionic-angular 3.4.2

System:

    Node       : v6.10.3
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10

I currently test my development by using Ionic View.

BTPrinter.connect error callback is late

When the BTPrinter is offline or BtPrinter is far away from phone device, below function's error callback is late. How can I decrease that time limit?

BTPrinter.connect(function(data){
alert("success");
},function(err){
alert("error");
}, "PrinterName");

required phonegap build

Sir,

I need phonegap build address of cordova-plugin-bluetooth-printer.

Please provide

Thanking you

Blue tooth Printer Connection

Hi, I am not able to connect my bluetooth printer ., getting connected first time and after few seconds immediately got connection aborted error.Please help me

How to print data in table format or print pdf

Hi,

Thank you for this wonderful plugin. is there any way that we can print string like table [formatted string].

for ex if table column data exceeds its width size then it will aromatically wraps string within that cell.

i tried by converting html dom element as canvas and send base64 string to printer but it prints ascii and non readable chars.

kindly let me if there are any ways to print pdf.

regards,

not printing data

I got success message but data is not print the data in printer can someone please help me what i did mistake

$scope.getconnect = function(printername){
alert(printername);
alert('Printer Start');
$scope.doc = "\n TESTING \n PULSA.1 \n KIOS SAYA \n Term : 10006062 \n Ref. No. Bank : 00000000050 \n PEMBELIAN VOUCHER \n manoj \n No Hp : manoj \n No. Seri : 0010101 \n Nominal : manoj \n \n \n ";
$scope.test = JSON.stringify($scope.doc);
alert($scope.test);

	BTPrinter.connect(function(data){
		alert(" Connected...");
		alert(data);
		BTPrinter.printText(function(data){
			alert("Success print");
			alert(data)
			BTPrinter.disconnect(function(data){
				alert("Success disconnected");
				alert(data)
			},function(err){
				alert("Error disconnecting!");
				alert(err)
			}, printername);
	},function(err){
		alert("Error Print!");
		alert(err);
	}, $scope.test);
	},function(err){
		alert("Error Connecting!!");
		//alert(err);
		alert(err);
	}, printername);
} 

Image printing

Hi, I'm developing a phonegap app with js and i need to print a logo and barcode. Are you working on this? or do you know any plugin that works and has image print support?

Service discovery failed

Once I connect printer and give print command, getting "service discovery failed". What could be the fix?

list

           function list()
    	{
    		try
    		{
    			window.BTPrinter.list(function(data){
		        alert("Success");
		        alert(data); //list of printer in data array
		    },function(err){
		        alert("Error");
		        alert(err);
		    })
    		}
    		catch(e)
    		{
    			alert(e.message)
    		}
    		
    	}

Always prompt for 'the cannot read property list undefined'

Ionic 2 Plugin iussue

Hello Team,
after installing the plugin it not call in ionic2. Please let me know what i need to do.

Thanks
Deepak

Option for selecting device type

if there is any option for selecting device type for our bluetooth printer plugin ? assume there a so any paired device in our mobile,then how can i select perticular bluetooth device to mobile . there is any option for that ? am waiting for your reply

BTPrinter variable undefined in phonegap dev mobile App

Hi,

I am getting undefined for the variable BTPrinter in phonegap developer mobile app.

I installed the plugin correctly. bluetooth is not working in my laptop so i have to check by connecting with mobile. In laptop when i put console BTPrinter is having value. kindly help me plz.

The problem is occurring only when i am using developer mobile app.

BTPrinter.list(function(data){
console.log("Success");
console.log(data); \list of printer in data array
},function(err){
console.log("Error");
console.log(err);
})

regards,

Printer Model confirmation

I need a confirmation about following printer model . Do they work with this library ? or if any other printer.

  1. SP-X501B is a thermal printer . SP-X501B

  2. AGPtEK® 58mm Mini Bluetooth/USB Pocket POS Thermal Receipt Printer for Android IOS . Here

I need to use any one of above printer to print the order (Restaurant Management ).

Safe print function (isConnected() workaround)

In my project I needed a reliable isConnected() function, to test connection status and reconnect if needed, and as a workaround, I used this function that tries to print and, if not connected, tries to connect and print again. Thus, the connection to the device is made automatically. Tested on a cheap chinese bluetooth printer connected to an android device.

safePrint() {
  let device = 'MTP-3';
  let text = 'safe print ok\n\n';

  this.safe_print_msg = 'printing text...';

  setTimeout(() => {
    BTPrinter.printText(data => {
      this.safe_print_msg = 'print ok, already connected!';
    }, err => {

      this.safe_print_msg = 'print ERROR, connecting...';
      setTimeout(() => {
        BTPrinter.connect(data => {

          this.safe_print_msg = this.msg = 'connected, printing again...';
          setTimeout(() => {
            BTPrinter.printText(data => {
              this.safe_print_msg = 'print ok';
            }, err => {
              this.safe_print_msg = 'print_ERROR';
            }, text);
          }, 0);

        }, err => {
          this.safe_print_msg = this.msg = 'connect ERROR';
        }, device);
      }, 0);

    }, text);
  }, 0);
}

Connect printer run twice

My print function run twice and below is my codes.

Can somebody advice me?

var printerName = $rootScope.printerName;
var canvas = document.createElement("canvas");
JsBarcode(canvas, "88881ID1|60000", {format: "CODE128"});
$rootScope.barcode = canvas.toDataURL("image/png");

$scope.testPrint = function() {
BTPrinter.connect(function(data) {
   BTPrinter.print(function(data) {
      BTPrinter.disconnect(function(data) {
            }, function(err) {
      }, printerName);
           }, function(err) {
   }, $rootScope.barcode);
      }, function(err) {
     }, printerName);
};

Is it possible print image in ionic 2 ?

i tried to print image with this plugin in ionic 1 and the result is nice as expected.
but when i tried to print image with this plugin in ionic 2, it print unknown character.

is it possible to print image in ionic 2 ?

thank you for this awesome plugin. keep up good work dude.

Failed to fetch plugin https://github.com/srehanuddin/Cordova-Plugin-Bluetooth-Printer.git via registry

cordova plugin add https://github.com/srehanuddin/Cordova-Plugin-Bluetooth-Printer.git while performing this action i am getting this issue.
Error: Failed to fetch plugin https://github.com/srehanuddin/Cordova-Plugin-Bluetooth-Printer.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.

How to resolve this issuecordova plugin add https://github.com/srehanuddin/Cordova-Plugin-Bluetooth-Printer.git while performing this action i am getting this issue.
Error: Failed to fetch plugin https://github.com/srehanuddin/Cordova-Plugin-Bluetooth-Printer.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.

How to resolve this issue

Nextline Printing

Hey great plugin.

Kindly tell me how to print multiple lines. I've used \n but the printer simply ignores any text after the first \n it sees.

Thank you

POS Command Sample

Hi, I am quite new in this printing area.

May I know if there are any sample of printing using pos command using this plugin?

Thank you.

Select printer

Hello!

I can get a list of connected blueetoth devices with BTPrinter.list, but I don't know how to select one and use it for printing. I understand that I have to use BTPrinter.printText function, but I suppose this must know which printer to use.

Error Print! bad base-64

Hi I have this error: ** Error Print! bad base-64 **
I use that print image method in this plugin, this is my code:
function printerDocument(printParam) {

	var tes='<div><img src="'+printParam.logo+'"/></div><br>';
     
	
		
	BTPrinter.connect(function (data) {
		
		console.log("Connected...");
		console.log(data);
		BTPrinter.print(function (data) {
			console.log("Success");
			console.log(data)
			BTPrinter.disconnect(function (data) {
				console.log("Success disconnected");
				console.log(data)
			}, function (err) {
				console.log("Error");
				console.log(err)
			}, "WOOSIM");
		}, function (err) {
			console.log("Error Print!");
			console.log(err)
		},tes);
	}, function (err) {
		console.log("Error Connecting!!");
		console.log(err);
	}, "WOOSIM");

printParam.logo is a base64 image

QR code printing example

  printQrCode() {
    const justify_center = '\x1B\x61\x01';
    const justify_left   = '\x1B\x61\x00';
    const qr_model       = '\x32';          // 31 or 32
    const qr_size        = '\x08';          // size
    const qr_eclevel     = '\x33';          // error correction level (30, 31, 32, 33 - higher)
    const qr_data        = 'http://stackoverflow.com/';
    const qr_pL          = String.fromCharCode((qr_data.length + 3) % 256);
    const qr_pH          = String.fromCharCode((qr_data.length + 3) / 256);

    BTPrinter.printText(data => {
      this.msg= 'QR code ok';
    }, err => {
      this.msg= 'QR code ERROR';
    }, justify_center + 
       '\x1D\x28\x6B\x04\x00\x31\x41' + qr_model + '\x00' +        // Select the model
       '\x1D\x28\x6B\x03\x00\x31\x43' + qr_size +                  // Size of the model
       '\x1D\x28\x6B\x03\x00\x31\x45' + qr_eclevel +               // Set n for error correction
       '\x1D\x28\x6B' + qr_pL + qr_pH + '\x31\x50\x30' + qr_data + // Store data 
       '\x1D\x28\x6B\x03\x00\x31\x51\x30' +                        // Print
       '\n\n\n' +
       justify_left);
  }

Struggling to get working

Just Doesn't want to print ?

<script> function testing(){ BTPrinter.printText(function(data){ console.log("Success"); console.log(data); },function(err){ console.log("Error"); console.log(err); }, "Print" ); disconnect(); } </script>
<script>
        function disconnect(){
   BTPrinter.disconnect(function(data){
console.log("Success");
console.log(data);

},function(err){
console.log("Error");
console.log(err);
}, "C065120505");
}
</script>

Bluetooth printing issue

Bluetooth print plugin working correctly in my phonegap app . but bluetooth printer not working . just connecting the device ,but nothg is printed . what will i do , need extra jar file to attach my app , please respond me

print text

Hi, when i'm using the printText code snippet, i get the error "Invalid action".

Regards.

printing html contents

I have convert to html to base64 but how to print it using this plugin.
could you please give me step by step to use this plugin.

Using plugin via PhoneGap build

Is it possible to use this plugin via PhoneGap Build?
Example...
<plugin name="cordova-plugin-device" spec="1.1.2" />
<plugin name="....." spec="..." />

IOS supported?

Hello
it's only providing the support on the android. Is there any supported features on ios ?

Thanks

Is it Possible to pass more than one parameters in bluetooth printer functions ?

Like this ,

BTPrinter.print(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, "String1","String2")

am using this function to pass two parameters but its occur invalid action . is it possible for passing more than one parameter to this printing function .

Hep barcode example

Can anyone help me with an example of how to print barcode?

Or is it not possible?

Help for you

Hey guys. I've been playing with this plugin since last night and faces some problem along the way. My initial setup connects to my bluetooth printer and send data to printer but doesnt print the text with no error log. Succeding test will also fail with error:read failed socket might blah blah.

Here's my solution, and this might help you as well.

  1. I dive into the SDK and sourcecode included with my printer and found out that the printer accepts GBK bytes so I set that to the BluetoothPrinter.java (line 261) should be mmOutputStream.write(msg.getBytes("GBK"));
  2. right below this line you have to flush the outputstream, like so: mmOutputStream.flush();
    that will solve the read failed error socket on succeding test.

I'll report back when i found something new, but right now my printer is working.
Thanks srehanuddin for the awesome plugin..one star for you brother.

Code Sample

Can anyone help me with an working sample of this plugin? i have tried to run the code after onDeviceReady but it doesnt show anything. also tried to write to console BTPrinter and window.BTPrinter but nothing would work. thanks

FontStyle and FontSize

Hi srehanuddin, thanks for the awesome plugin! btw, can i change font style (bold, italic,etc) or fontsize?

regards,

error : read failed, socket might closed or timeout, read ret: -1

  1. When i want to printting i have error read failed, socket might closed or timeout, read ret: -1 anyone has same issue like me ? sometimes i must restart my bluetooth and printer device

  2. My Code `$scope.printbtt = function(opr,noTelp,valueOpr){
    console.log('Printer Start');

    $scope.doc = "\n TESTING \n PULSA.1 \n KIOS SAYA \n Term : 10006062 \n Ref. No. Bank : 00000000050 \n PEMBELIAN VOUCHER \n "+opr+" \n No Hp : "+noTelp+" \n No. Seri : 0010101 \n Nominal : "+valueOpr+" \n \n \n ";
    $scope.test = JSON.stringify($scope.doc);

    console.log($scope.test);

    BTPrinter.connect(function(data){
    console.log(" Connected...");
    console.log(data);
    BTPrinter.printText(function(data){
    console.log("Success print");
    console.log(data)
    BTPrinter.disconnect(function(data){
    console.log("Success disconnected");
    console.log(data)
    },function(err){
    console.log("Error disconnecting!");
    console.log(err)
    }, "WOOSIM");
    },function(err){
    console.log("Error Print!");
    console.log(err)
    }, $scope.test);
    },function(err){
    console.log("Error Connecting!!");
    console.log(err);
    alert(err);
    }, "WOOSIM");

    }` why cannot print my text ?

Any Option for selecting paired device ?

Any Option for selecting paired device in selectbox generated with bluetoothprinter.java , there are so any paired devices are available ,then can i selected printers. need to display selectbox for selecting devices.

Btprinter is not defined

Hello,
I am using Phonegap and console printed this information when I tried this plugin:
Uncaught ReferenceError: BTPrinter is not defined
But if I use cmd and check plugins: .go to app folder and type phonegap plugin list
I see: cordova-plugin-bluetooth-printer 0.0.1-dev "BluetoothPrinter"

Do you know where can be problem?

confix.xml:
<gap:plugin name="cordova-plugin-bluetooth-printer" />

Thank you!

Invalid action

I am trying to print some string using this plugin but I got error

When trying to go to BTPrint.printText function, it gaves me invalid action

then I got Read failed, socket might closed or timeout, read ret: -1 after click the same button.

My code as follows;

     $scope.connectPrinter = function(name) {

       $scope.test = "\n Muahahahahah \n Muahahahahah \n Muahahahahah \n \n \n \n";

       BTPrinter.connect(function(data) {
         alert("Success");
         alert(data);
         
        BTPrinter.printText(function(data) {
          alert("Success");
          alert(data);

          BTPrinter.disconnect(function(data) {
            alert("Success");
            alert(data);
          }, function(err){
            alert("Error");
            alert(err);
          }, "name")

        }, function(err){
          alert("Error");
          alert(err)
        }, $scope.test)
         
        }, function(err){
          alert("Error");
          alert(err);
        }, name)
     };

Can anyone assist me?

[Bugs?|Feat] Connection management is hard

In the current state connection management is very difficult, the only connection things we have is connect, disconnect, and with a parameter also disconnect all.

However there's no way to tell if you're already connected, currently i have to try and catch a disconnect operation no matter what, even if it's the first connection (just to be safe).

In most parts of my code i have catch blocks that trigger a disconnect, connect again and retry the current operation.

As some of you could notice, this leads to some overhead because i have to call some functions many times even if it is not necessary, and yet errors still occurs.

Say i print, some times the connection breaks or something like that, then it tells me some errors, sometimes trying to print again fix the issue, other times i have to shut down the printer, close the app and open again in order to get rid of the issue.

Is it possible to create a function to check if the connection is OK?, not just open but that the data is actually being received by the printer (valid connection)?

Error: Unknown provider: BTPrinterProvider <- BTPrinter <- PrintCtrl

I have been trying to use this plugin for some time now with little success.

Here is my controller

angular.module('starter.controllers', ['ionic', 'starter.controllers','ngCordova'])

.controller('PrintCtrl', function($scope, BTPrinter) {

BTPrinter.list(function(data){
console.log("Success");
console.log(data); //list of printer in data array
},function(err){
console.log("Error");
console.log(err);
})

})

I keep on getting this error message

Unknown provider: BTPrinterProvider <- BTPrinter <- PrintCtrl

Help!

Hii

How can use this plugin in config.xml file not by Using the Cordova CLI and NPM?
I added this line into my config.xml but got an error message on adobe phonegap builder;
<gap:plugin name="Cordova-Plugin-Bluetooth-Printer" source="npm" />

error message:

Error - The following plugin, plugin version or a dependancy of this plugin is not on npm: Cordova-Plugin-Bluetooth-Printer

Println needs a message

Hai guys

I found a problem when connect to get the message 'println needs a message'

Please help
thank you

Cannot read property 'connect' of undefined

Hello,
Error log:
Cannot read property 'connect' of undefined

My code:
window.BTPrinter.connect(function(data){
alert("Success");
alert(data);
},function(err){
alert("Error");
alert(err);
}, "SPP-250")

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.