AndBondStyle / niimprint

Python library for Niimbot label printers. Supports D11/B21/B1 via bluetooth or USB.
MIT License
215 stars 31 forks source link

setting up for printing #1

Open nohkumado opened 11 months ago

nohkumado commented 11 months ago

transcription of my problems setting up the printer:

                    just got a hand on such a printer, and tried your fork, but ATM it won´t do...
                    i have a png file with a qr code inside, 171x171
                    i added to your code a print statement (the highest of my abilities in python...)
                    and indeed, it prints 171x171 but then
                    it failed with an image too big assertion...

                    BTW i tried poetry, but that failed too .... wanted some kde stuff i haven´t...

                    so i tried in the cloned dir directly...
                    python3 fails:

                    python3 niimprint -m b1 -i ~/pixel_backup/sdcard/Download/qr.png
                    Traceback (most recent call last):
                      File "<frozen runpy>", line 198, in _run_module_as_main
                      File "<frozen runpy>", line 88, in _run_code
                      File "/home/bboett/AndroidStudioProjects/niimprint/niimprint/__main__.py", line 6, in <module>
                        from niimprint import BluetoothTransport, PrinterClient, SerialTransport
                    ModuleNotFoundError: No module named 'niimprint'

Андрей: Hi, try running export PYTHONPATH=$(pwd) before running the python command. You should use python3

me: now i get farther: python3 niimprint -m b1 -i testqr.png opening testqr.png size : 171x171 Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/bboett/AndroidStudioProjects/niimprint/niimprint/main.py", line 82, in print_cmd() File "/usr/lib/python3/dist-packages/click/core.py", line 1157, in call return self.main(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bboett/AndroidStudioProjects/niimprint/niimprint/main.py", line 78, in print_cmd printer.print_image(image, density=density) File "/home/bboett/AndroidStudioProjects/niimprint/niimprint/printer.py", line 104, in print_image self.set_label_density(density) File "/home/bboett/AndroidStudioProjects/niimprint/niimprint/printer.py", line 253, in set_label_density return bool(packet.data[0]) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'data' Андрей: Sorry, the error message is a little cryptic, I'll fix it later. Basically, it means your printer doesn't respond for some reason... I'm assuming you're connecting it via USB and relying on auto-detecting the serial port. Can you show me the output of lsusb command (list usb devices) and also ls /dev/serial/by-id (list serial ports). Also check if your printer is turned on: when you connect it via USB, it starts charging, but you need to press the power button for it to power on.

me: and eventually if you can help me out with the printing itself....? i have some strangeness... i print out a qr code, source is a svg file to allow easier testing.... so at 300 i hit the too big limit.... 299 prints out the qr code with 1cm place left on the left side, and cutting off the last 3mm on the bottom.....

and thats completely weird?? the labels are 4cm wide and 6 cm long, so depth should really are a problem, and i should be able to use the full width? so there is some systemic problem i don´t seem to grasp...

Андрей :

About your images, Right now the code is a little naive and probably just uses some default value (72dpi probably). So my advice to you is to use a .png right now. To print on a 40x60 mm label you should pass a 320x480px image (8px/mm, as said in the readme). Also, these printers are not very accurate in terms of print alignment, so don't try to print something very close to label edges (add a 1-3mm margin).

me: the strange thing is, i just tested with an image with some text, and now i can address the full width.... (need to look if there are 5cm wide labels now :D ) and indeed you are right with the margins.... depending on how good the roll is aligned you can have bad surprises,,,,, so the problem probably is my generated qr code.... will have to dig into the svg file itself :(

again: anyway thanks a lot for helping me set this up and thanks for your efforts for this project!

ciao bboett

AndBondStyle commented 11 months ago

Oh, I see you already posted :) To sum up, following issues need some attention:

yveszemp commented 5 months ago

Hello i have the same Problem 'ModuleNotFoundError: No module named 'niimprint'' i try to set PYTONPATH, but which path i need to set ? Where is the module niimprint located ?

AndBondStyle commented 5 months ago

@yveszemp set it to the root directory of the project (directory with .gitignore, pyproject.toml etc.). Also refer to https://github.com/AndBondStyle/niimprint/issues/24#issuecomment-2105664638

If you're on windows: set PYTHONPATH=%cd%
If on mac/linux: export PYTHONPATH=$(pwd)

yveszemp commented 5 months ago

wow great, many thanks for the ultra fast Reply. now it works.

yveszemp commented 5 months ago

a little question, is there a way to support to print PDF ?

AndBondStyle commented 5 months ago

@yveszemp well, yes, but it needs to be implemented. Right now it's only possible by converting pdf into image

yveszemp commented 5 months ago

ok great, i will check to convert the file. Many Thanks.