Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to print the Bold Letters. #57

Open
saibrahamaiah opened this issue Jan 2, 2018 · 8 comments
Open

How to print the Bold Letters. #57

saibrahamaiah opened this issue Jan 2, 2018 · 8 comments

Comments

@saibrahamaiah
Copy link

How to print the Bold Letters and Change the font size.

@Darkarmour
Copy link

The following ESCPOS Commands(HexaDcimal) might be useful
1B 45 01 => Bold,
1B 45 00 => Without Bold,
1B 21 01 => Small sized font,
1B 21 00 => Normal sized font

@saibrahamaiah
Copy link
Author

Thank You @Darkarmour for your reply. Can please give me any example for bold. Where the use these commands. I don't want entire example just give important those 10 lines only.
Thank You.

@Darkarmour
Copy link

command = '1B 40'; //Initialize the Printer to accept POS Commands
command += '1B 61 01'; //Initialize Center Alignment
command += '1B 21 01'; //Initialize small sized font
command += '1B 45 01'; //Initialize Bold
command += HEXA('Dark'); //Get the hexadecimal value for the name 'Dark'
command += '0A'; //Next line feed
command += '1B 21 00'; //Initialize normal font
command += '1B 45 00'; //Initialize withour bold
command += HEXA('Armour'); //Get the hexadecimal value for the name 'Armour'
command += '0A'; //Next line feed

@saibrahamaiah
Copy link
Author

Hi
First of all Thank You @Darkarmour for your reply.
Suppose if i want print Hello World in Bold Letters
like as below
command = '1B 45 01' + 'Hello World' + '1B 45 01';
See code here

this.print(command)
 print() {        
      BTPrinter.printText((data) => {                       
              this.feed();
      }, (err) => {            
          alert("Error")
      }, command);
  };

  feed() {
      BTPrinter.printPOSCommand((data) => {
      }, (err) => {            
          alert("Error")
      }, "0C")        
  };

Is this correct ?
Please tell me.

@Darkarmour
Copy link

Darkarmour commented May 18, 2018

Hi,
The following needs to be done for Bluetooth Printing with this Plugin,

  • Check for Bluetooth connectivity
  • Print POS Command/ text
  • Disconnect the printer (If necessary)
    Make sure that you have done the above things right.

And as for the Command is concerned
command = '1B 40 ';//Initiliase
command += '1B 45 01 ' + hex('Hello World') //Convert the string to its hexa value
If you face any more issues, let know me of the issue.

@saibrahamaiah
Copy link
Author

saibrahamaiah commented Jun 25, 2018

Hi Darkarmour, Thank you for your reply. But Iam still facing problem. I am getting Socket closed issue
I tried like
but it prints one time bold hex() not working. It is showing function not defined. So i used

toHex(str) {
        var hex = '';
        for(var i=0;i<str.length;i++) {
            hex += ''+str.charCodeAt(i).toString(16);
        }
        return hex;
    }
    ```

this.printData = '1B 40 ';
this.printData += '1B 45 01 ';
this.printData += this.toHex('Hello World')

    BTPrinter.printPOSCommand((data) => {            
        this.disconnect();
    }, (err) => {
        alert(err)
    }, this.printData)
    
    BTPrinter.printText((data) => {            
        this.util.alert("ok", "Info", "Printing...", null, null);
        this.feed();            
    }, (err) => {
        alert(err)
    }, this.printData);       
It printed bold letters but diffrent characters displayed.
Can u please forward working example to my mail,
this is my mail sai.brahamaiah@gmail.com

@Darkarmour
Copy link

Hi @saibrahamaiah!

  1. It printed bold letters but different characters displayed. - This issue can happen due to the incorrect conversion of HexCode of the string. Please verify that you send the correct HexCode
  2. Socket closed issue - This might occur due to the Bluetooth connection getting closed before the printing even happened. So try it with a timeout for disconnect().

Try changing with this. If you still face the issue, let me know.

@sagar999-stack
Copy link

public boolean PrintfData(byte[]data) {
    mSockManager.threadconnectwrite(data);
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if (mSockManager.getIstate()) {
        return true;
    }
    else {
        return false;
    }
}

how to bold this byte array?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants