Giter Club home page Giter Club logo

printooth's People

Contributors

ajaygalagali avatar danielpsantiago avatar hansemannn avatar mazenrashed avatar sakkeerhussain avatar tspoke avatar watcharinwork avatar yousef96m 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

printooth's Issues

Error in ScanningActivity

With the migration to androidx, the lib must be imported in build.gradle (:app):

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

Because, the Android Studio get this error:
[+] android.view.InflateException: Binary XML file line #15: Error inflating class androidx.swiperefreshlayout.widget.SwipeRefreshLayout.
[+] java.lang.ClassNotFoundException: Didn't find class "androidx.swiperefreshlayout.widget.SwipeRefreshLayout"

So, as in ScanningActivity.kt don't have this import:
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

We have to import that in our gradle file =D

Image Alignment

I'm trying to print image with center alignment, but whatever alignment I set on my ImagePrintable, the image result is always aligning to the left, while the TextPrintable alignment works just as intended.

Is there anything else that I should add to my code to make the image appear on the center?

Here's my code:

        ArrayList<Printable> al = new ArrayList<>();
        Resources resources = getResources();           

        Bitmap image = BitmapFactory.decodeResource(resources,R.drawable.logo);
        al.add(new ImagePrintable.Builder(image)
                .setAlignment(DefaultPrinter.Companion.getALIGNMENT_CENTER())
                .setNewLinesAfter(1)
                .build());

        al.add( (new TextPrintable.Builder())
                .setText(" Hello World")
                .setAlignment(DefaultPrinter.Companion.getALIGNMENT_CENTER())
                .setNewLinesAfter(1)
                .build());

        printing.print(al);

New Logo for Printooth

Hi,

I'm doing logo for open source projects. When I was doing research at Github, I saw your project. If you want, we can design a logo according to your wishes.

cheers.

HTML support?

Hello this library is great! Is it possible to print HTML?

Open Converter

package com.mazenrashed.printooth.data.converter
Could you change
fun toByteArray(input: String): ByteArray {...}
to
open fun toByteArray(input: String): ByteArray {...}
I need it to use multibyte encoding, such as UTF-8
Thank you for this great lib

Binary XML file line #16 in layout/activity_scanning:

I am getting this error

Binary XML file line #16 in com.genericprinter.ca:layout/activity_scanning: Error inflating class androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Caused by: java.lang.ClassNotFoundException: androidx.swiperefreshlayout.widget.SwipeRefreshLayout

Print not working

Ive tried on POS printer its responding and connected but not print the data. Any help?

Print Unicode

Hi.
I have a problem. I Can not print character Unicode. Please help me
Example: ê, ề, ế, ệ, ễ, ể

Thanks

smaller font

how to set font smaller than DefaultPrinter.FONT_SIZE_NORMAL ?
0x00 is normal
0x10 is large
how much for smaller than normal?

Adjust Line Spacing

Everything Working Fine but i want reduce less than getLINE_SPACING_30. how i can do it?

what is the value for variable LAST_VERSION

unable to find value of variable LAST_VERSION in

implementation 'com.github.mazenrashed:Printooth:${LAST_VERSION}'

I am currently unable to add library because I do not know the version of library.

Text dont print, the paper comes out blank

Hi,
How i said in the title, i implement the printooth code to print in my android studio app, i follow every step but when i go to print, the printer roll out the blank white paper but dont write anything.
How can i solve? i try different printer but still the same problem

Auto Reconnect

Hi , can you add auto reconnect feature to this library ?
Or can you point me into right direction so that i can write it ?

Printing import error

project cannot import Printing if I write this import com.mazenrashed.printooth.utilities.Printing; Main activity red line Printing

Print Barcode

Salam mazin,

is this lib support barcode printing ?

Thanks in advance

Printing Image or QR-code

Respected Developer,
First of all i want to say thank you to you for this easy to use library. I want to know, how we can print images or QR code using this library ?

Print bitmap

Hi, nice library easy to use. Can I print a bitmap? I'll create a bitmap in my application, but your PrintableBuilder can only send resources from application.

Charecter encoding

Hi,

Thanks for this library. I set it up on my Android project and successfully printing English characters. How can I sen another code page encoding?

I' ve seen on DefaultPrinter.kt how you define some Byte vars like CHARACTER_CODE_ARABIC_CP720.

How can I define for a different Language other than Arabic or English?

Thank you in advance

Android-x Support

android.support.v4.widget.SwipeRefreshLayout changed to => androidx.swiperefreshlayout.widget.SwipeRefreshLayout

ScanningActivity Error inflating class SwipeRefreshLayout

Hi!, I'm using this great lib with java and androidx. But when I try to open intent ScanningActivity I get this error.....
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.mazenrashed.printooth.ui.ScanningActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.swiperefreshlayout.widget.SwipeRefreshLayout" on path: DexPathList[[zip file "/data/app/com.example.myapplication-ij5HA_Uou0mV2FSe1dg4sg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-ij5HA_Uou0mV2FSe1dg4sg==/lib/arm64, /system/lib64, /vendor/lib64]]

Text not appearing

When I print no text appears when the paper comes out of the printer. What could be the problem?

Printing Images

Printing Images doesn't work. And when i try make MyPrinter class than implements Printer, It says that must include useConverter method. Could you tell me more about the method
override fun useConverter(): Converter {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

How to build custom converter?

I saw in one example that you were using ArabicConverter. How to write converter for Russian/Cyrillic converter? Setting character code doesn't help...

Not Printing 1+5

I am using oneplus 5 goojprt recipet printer. But no response from printer.

Can not print more than 4 feet long receipt

I am trying to print a receipt that's longer than 4 feet, but it's not working.
it prints about about 3 feet then stop with a red bulb on the printer.
could you tell me how to resovle this issue ?

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

Hi, I have a list of items with a button which I can press and print the item info. Printing is fine if I press a button and wait for a while until I press again another one. But if I press two buttons too close in time I get this error and it prints only the first one:

W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@a1962b9, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@cf996fe, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@8bade5fmSocket: android.net.LocalSocket@3cbd0ac impl:android.net.LocalSocketImpl@8647175 fd:java.io.FileDescriptor@2d4250a, mSocketState: INIT D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@a1962b9, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@cf996fe, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@8bade5fmSocket: null, mSocketState: CLOSED read failed, socket might closed or timeout, read ret: -1

I just have a clickListener for the buttons:

binding.button.setOnClickListener {
    Printer.print(organisationName, item)
    viewModel.editOrderStatus(item.id, item.statusId+1) 
}


fun print(organisationName: String, order: Order) {
    if (Printooth.hasPairedPrinter()) {
        var printables = ArrayList<Printable>()
        var printable = TextPrintable.Builder()
            .setText(organisationName) //The text you want to print
            .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
            .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_BOLD) //Bold or normal
            .setFontSize(DefaultPrinter.FONT_SIZE_LARGE)
            .setUnderlined(DefaultPrinter.UNDERLINED_MODE_ON) // Underline on/off
            .setCharacterCode(DefaultPrinter.CHARCODE_PC437) // Character code to support languages
            .setLineSpacing(DefaultPrinter.LINE_SPACING_60)
            .setNewLinesAfter(1) // To provide n lines after sentence
            .build()
        printables.add(printable)
        Printooth.printer().print(printables)
    }

}

Any workaround I can have here?
Thanks!

Printer prints again after bluetooth reset

Hi,
I was trying Printooth in a proyect I'm working on. I was able to use the library with a bluetooth printer, but there is a problem. My code schedules to reset ( off /on) the bluetooth after a few minutes and, if I've printed something before, my printer prints again the same thing without sending the order.

This are the steps of the code:

  1. Initialize app.
  2. Pair Printer with Scanned Device List
  3. Button -> print some text.
  4. Bluetooth reset (OFF / ON)
  5. Printer prints again.

I don't know if is an issue with the library that doesn't close the BT conection or It's just my printer that has this behaviour.

Here is the code of the printing scenario:

` PairedPrinter printer = Printooth.INSTANCE.getPairedPrinter();

        ArrayList<Printable> printables =  new ArrayList<>();
        Printable printable = new TextPrintable.Builder()
                .setText("Hello World" )
               
                .build();
        printables.add(printable);
  
        Printooth.INSTANCE.printer().print(printables);
   `

Thanks in advance.

Print image twice

Respected Developer,
I had a problem when i tried for printed a sequential image twice but the result return such as this :
66614866_925314921139338_2378107792473980928_n
Please help me fix it .
Have a nice day.
Thanks

Thermal printer in TPCL, RCT mode issue!!!

I developed an app using Printooth, everything is fine when the printer is in ESC/POS mode, but if I switch the printer's configuration to TPCL or RCT (for label paper feed control) it looks like my app send the command, the printer sign as receiving the command, but just doesn't print.

If anyone have ever developed Android App for Thermal label printer, please share your experience.

Missing Permission for app targets Android 9 (API level 28)

Hi. For Apps targetting API 28 they need to declare location permissions
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> to be able to scan for devices. If app has not requested this permisson the ScanningActivity can only see already paired devices.
This permission can be included in the app or somewhere in the ReadMe

Not showing list of Unpaired devices

Hi,
When initiating the intent for Scanning Acitivty. Is it only supposed to show a list of devices that have been previously paired in the past or is it suppose to show all the list of devices.

Here is my java code
Intent scanDeviceIntent = new Intent(this, ScanningActivity.class);
startActivityForResult(scanDeviceIntent, ScanningActivity.SCANNING_FOR_PRINTER);

@OverRide
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ScanningActivity.SCANNING_FOR_PRINTER && resultCode == Activity.RESULT_OK) {
Log.e(TAG, "Scan completed:: ");
PairedPrinter pairedDevices = Printooth.INSTANCE.getPairedPrinter();
Log.i(TAG, "name: " + pairedDevices.getName());
TextView printerName = (TextView) findViewById(R.id.printerName);
printerName.setText(pairedDevices.getName());
}
}

In the list of devices, I cannot see any devices even though bluetooth is on for other devices around

ScanningActivity has leaked IntentReceiver

this problem was triggered when user tries to select a bluetooth device during the scan.
It looks like you forgot to call unregisterReceiver().

Activity com.mazenrashed.printooth.ui.ScanningActivity has leaked IntentReceiver com.mazenrashed.printooth.utilities.Bluetooth$3@4ee1a0b that was originally registered here. Are you missing a call to unregisterReceiver()?

or am i forget to initialized something ?

How to use Printooth.setPrinter

Basically, i wanted to use more than one printer. isit possible? and how do i determine which printer is paired to the Printooth. I couldn't find any documentation out there that are saving printer name, if any, can you provide one.
Thanks

Not working in Android 10

Hi, Does any one has Printooth working in Android 10?

I made an app and use this great printer function, works perfect in Android 9 but some one tested in Android 10 and does not work.

Thanks for your advice or suggestions.

Print Two Different Text Alignment on same line

Hi @mazenrashed ,
need to know how to print 2 different text alignment (right and left) on the same line.
E.g:
| Items's Name...............................Price |
| Pen A.............................................$ 5.21 |

where the "|" char is edge of paper, and "." is space char

my current code is like bellow:

printables.add(new TextPrintable.Builder()
                    .setText("Pen A")
                    .setAlignment(DefaultPrinter.Companion.getALIGNMENT_LEFT())
                    .build()
            );
printables.add(new TextPrintable.Builder()
                    .setText("$ 5.21")
                    .setAlignment(DefaultPrinter.Companion.getALIGNMENT_RIGHT())
                    .setNewLinesAfter(1)
                    .build()
            );

produces:
| .............................................Pen A$ 5.21 |

ALIGNMENT_LEFT & ALIGNMENT_RIGHT

The thing is TextPrintable with alignment_left without setting newLinesAfter makes text to move end.
For example, I want to align two texts at the same line. One with left alignment the next one right alignment.

    add(
            TextPrintable.Builder()
                .setText("${documentTitle}")
                .setCharacterCode(DefaultPrinter.CHARCODE_PC866)
                .setAlignment(DefaultPrinter.ALIGNMENT_LEFT)
                .build()
        )

        add(
            TextPrintable.Builder()
                .setText("${documentNumber}")
                .setCharacterCode(DefaultPrinter.CHARCODE_PC866)
                .setAlignment(DefaultPrinter.ALIGNMENT_RIGHT)
                .setLineSpacing(LINE_SPACING_1)
                .setNewLinesAfter(1)
                .build()
        )

This make whole both text align to right.

bluetooth callback issue

when i select device from scanning activity then in result i get this error
getBluetoothService() called with no BluetoothManagerCallback

i have search in depth your liberary file and i found that you have missed some code right here in bluetooth class

ConnectThread(BluetoothDevice device, boolean insecureConnection) {
Bluetooth.this.device = device;
try {
if (insecureConnection) {
Bluetooth.this.socket = device.createInsecureRfcommSocketToServiceRecord(uuid);
} else {
Bluetooth.this.socket = device.createRfcommSocketToServiceRecord(uuid);
}
} catch (IOException e) {
if (deviceCallback != null) {
deviceCallback.onError(e.getMessage());
}
}
}

after this try

try {
if (insecureConnection) {
Bluetooth.this.socket = device.createInsecureRfcommSocketToServiceRecord(uuid);
} else {
Bluetooth.this.socket = device.createRfcommSocketToServiceRecord(uuid);
}
} catch (IOException e) {

if exception occured you need to look for another connection which is also used commonly
that is

Method m = device.getClass().getMethod("createRfcommSocket", Integer.TYPE);
Bluetooth.this.socket = (BluetoothSocket) m.invoke(device, new Object[]{1});

No printing at all

Hi there,

I've followed your readme steps but it doesnt work unfortunately.

...
startActivityForResult(Intent(this, ScanningActivity::class.java), ScanningActivity.SCANNING_FOR_PRINTER)
...
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        if (requestCode == ScanningActivity.SCANNING_FOR_PRINTER && resultCode == Activity.RESULT_OK) {

 var printables = ArrayList<Printable>()
            var printable = TextPrintable.Builder()
                    .setText("Hello World")
                    .build()
            printables.add(printable)
            Printooth.printer().print(printables)
}
}

I receive no errors only those debug messages and the printer is paired successfully
D/printer: com.mazenrashed.printooth.data.PairedPrinter@90312a

D/BluetoothAdapter: cancelDiscovery
D/BluetoothAdapter: cancelDiscovery = true
D/BluetoothUtils: isSocketAllowedBySecurityPolicy start : device null
W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback

The app is running on android 9

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.