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

setting up for printing #1

Open
nohkumado opened this issue Nov 23, 2023 · 7 comments
Open

setting up for printing #1

nohkumado opened this issue Nov 23, 2023 · 7 comments

Comments

@nohkumado
Copy link

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
Copy link
Owner

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

  • Make a note about PYTHONPATH in readme
  • Make a note about powering on the printer in USB mode
  • Make error messages less cryptic (e.g. when device times out in USB mode)
  • Add an additional check of inserted label roll (via RFID) and compare it to image dimensions
  • Allow using .svg files with proper DPI conversion

@yveszemp
Copy link

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
Copy link
Owner

AndBondStyle commented May 13, 2024

@yveszemp set it to the root directory of the project (directory with .gitignore, pyproject.toml etc.). Also refer to #24 (comment)

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

@yveszemp
Copy link

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

@yveszemp
Copy link

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

@AndBondStyle
Copy link
Owner

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

@yveszemp
Copy link

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

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