Giter Club home page Giter Club logo

Comments (29)

belono avatar belono commented on May 28, 2024 2

Ok, I think we are getting closer.

According to page 24 of the printer's technical reference the maximum dots x line for 76mm paper width is 200. This is the value we have to supply at the media.width.pixels field in the TM-U220 profile.

You can force this value to be used by the printer's instance in order to test it beforehand:

import escpos.printer

opt = {
        "impl": "bitImageColumn",
        "high_density_vertical": False,
        "high_density_horizontal": False,
        "center": True,
    }
p = escpos.printer.File("/dev/usb/lp0", profile="TM-U220B")
p.profile.profile_data["media"]["width"]["pixels"] = 200
p.qr("https://de.wikipedia.org", native=False, image_arguments=opt)
p.cut()

What is the output now? It should be centered.

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024 2

Yes the value in the profile was the problem.
Now the QR code are correct aligned:
Pol1

Do have create an PR for it an the profile developers?
An I have found an second problem, which affects the bar code printing. I will open an separate issues for it.
Thanks for the work.

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024 1

@belono it will result in:
"1A21C1E01P0https://de.wikipedia.o"

from python-escpos.

belono avatar belono commented on May 28, 2024 1

@tuxmaster5000
The oversize of the image should be due to the difference between the image dpi and the printer dpi resolution that we are not handling at the image method.
Maybe the fragment_height param can be of help, but if it is not, I think you should externally adjust the image size before issue the command.

@patkan
The issue origin is that we are defaulting to high density = True for both horizontal and vertical parameters in the image() method that translates respectively to mode 32 and 33 of the ESC * command. Well, those modes are not supported by, at least, the TM-U220 and TM-U230 models as stated in the command reference (screenshot below), and is probably the cause of some opened issues like #508.

Screenshot 2023-12-03 at 19-03-56 ESC - TM Printer - ESC_POS Command - Tech Reference - POS - Epson

I think we should find a way to automatically switch to high_density_horizontal=False, high_density_vertical=False on the models that only support modes 0, 1. Maybe a new capabilities profile field?

from python-escpos.

patkan avatar patkan commented on May 28, 2024 1

@belono How about as a hotfix we allow a dict to be passed to qr() that will be used for the arguments of image() (explicitely set values through one of qr's image arguments should be overwritten and deprecated in the future?!).

In the long term an "automatic" setting based on capability would be great. Maybe we add a feature called bitImageColumnHighDensity or something?

from python-escpos.

belono avatar belono commented on May 28, 2024 1

Great!!!

Do have create an PR for it an the profile developers?

Yes, please do it.

Thank you for your fast feedback and testing.
I'm looking forward to that barcode issue. 😉

from python-escpos.

patkan avatar patkan commented on May 28, 2024

Hi, could you please try this with the most recent v3.0?

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

The result is the same.
the qr and the image function prints only garbage.
Using the cups filter from epson an print the png file via:
lpr -P Epson /tmp/QR_deWP.svg.png
will work. So the printer itself will be ok.

from python-escpos.

patkan avatar patkan commented on May 28, 2024

Thank you! Since you are forcing the implementation to bitImageColumn, are you sure that a) your printer supports that implementation and b) that is the same implementation used by the cups driver. (Maybe try to get a dump of the raw data stream)

Have you tried the other implementations? If yes, the next step would be that we have a look at the actual output. (To see if there is an implementation issue)

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

In the device list, the printer is listed as support bitImageColumn only.
For the cups driver you can take a look in the C source code.:
https://download.ebz.epson.net/dsc/du/02/DriverDownloadInfo.do?LG2=EN&CN2=US
&CTI=205&PRN=Software&OSC=LX
The "tmx-cups-src-ImpactReceipt-3.0.0.0.tar.gz" will contain all code.
Set the impl to bitImageRaster or graphics, will also result in garbage code.

from python-escpos.

belono avatar belono commented on May 28, 2024

Hi @tuxmaster5000 !

What is the output when using the qr() method?

import escpos.printer
p = escpos.printer.File("/dev/usb/lp0", profile="TM-U220")
p.qr("https://de.wikipedia.org" , native="false", impl="bitImageColumn")

from python-escpos.

patkan avatar patkan commented on May 28, 2024

Could you please try the same with the Dummy printer and then give us the content of Dummy.output?

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024
p = escpos.printer.Dummy(profile="TM-U220")
p.qr("https://de.wikipedia.org" , native="false", impl="bitImageColumn")
print(p.output)

Will result in:

b'\x1d(k\x04\x001A2\x00\x1d(k\x03\x001C\x03\x1d(k\x03\x001E0\x1d(k\x1b\x001P0https://de.wikipedia.org\x1d(k\x03\x001Q0'

from python-escpos.

belono avatar belono commented on May 28, 2024

@tuxmaster5000
Please, try setting the high_density_vertical param to False in the image method:`

p.image("/tmp/QR_deWP.svg.png", impl="bitImageColumn", high_density_vertical=False)

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

Now the printer prints an QR code, but it is complete miss formatted.
WLAN1

from python-escpos.

belono avatar belono commented on May 28, 2024

Now add the parameter high_density_horizontal=False, please.

p.image("/tmp/QR_deWP.svg.png", impl="bitImageColumn", high_density_vertical=False, high_density_horizontal=False)

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

Hi @belono, now the QR code will be quadratic, but don't fit on the paper.
I have added an sample using cups and python. The size can be bigger, this will not be an problem, as far the image will fit on the paper.
WLAN1

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

@belono the image() call is only an workaround, because the qr() also fails.
Because I will print QR codes, an working qr() call will be the best option.

from python-escpos.

belono avatar belono commented on May 28, 2024

the image() call is only an workaround, because the qr() also fails

When the printing of qr codes is not supported natively by the printer as in the TM-U220 model there is the param native=False of the qr() method to render an image of the qr code and send it out to the printer through the image() method, but as the image() method defaults are incompatible with your printer, it ends up failing to print the image (qr code).
That's the reason why you, by the moment, have to workaround the qr code print out by externally generate the qr code image and send it manually to the printer through the image() method switching to the non default high_density_horizontal=False, high_density_vertical=False params to match your printer's capabilities.

Because I will print QR codes, an working qr() call will be the best option.

By fixing the image() method to switch to those values automatically on printers that don't support the defaults would fix both the image and qr code outputs on those printers.
On a second stage we could look at the size mismatch and try to fix it.

It would be great if you could make some tests during the process. ;-)

from python-escpos.

patkan avatar patkan commented on May 28, 2024

Here you can find the current lib as of 5914c7c (this includes #600):
pyescp3.1.dev6.zip

With this qr has a new argument image_arguments to which you can pass a dict with all arguments that should be passed to image().

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

I have tried, an qr code will be printed, but it looks deformed. I think the with must be doubled or?
My code snip:

import escpos.printer
p = escpos.printer.File("/dev/usb/lp0", profile="TM-U220")
opt = {
        "impl": "bitImageColumn",
        "high_density_vertical": False,
        "center": True,
    }
p.qr("https://de.wikipedia.org" , native=False, image_arguments=opt)

And the result:
WLAN1

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

And adding:
"high_density_horizontal": False,
will result in:
wiki1

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

Are there any new code that I can test?

from python-escpos.

belono avatar belono commented on May 28, 2024

Are there any new code that I can test?

Disable center?

opt = {
        "impl": "bitImageColumn",
        "high_density_vertical": False,
        "high_density_horizontal": False,
        "center": False,
    }
p.qr("https://de.wikipedia.org", native=False, image_arguments=opt)

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

Yes now it looks much better. So now the center option looks like broken to or?
Pol1

from python-escpos.

belono avatar belono commented on May 28, 2024

So now the center option looks like broken to or?

It was my first thought but the centering code seems correct to me. 🤔
On the other hand image centering is calculated based on the media.width.pixel value of the TM-U220 capabilities profile which is set to 400px for a paper width of 76mm but the printer also supports 69.5mm or 57.5mm paper width with different number of pixels per line.
What is your paper size?

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

I use the 76mm role, because it will be the default for it. In the original profile for the TM-U220 80mm was noted, but this is wrong. For the TM-U220B profile I have correct it to 76mm. But it can be that also the other default values are wrong.

from python-escpos.

tuxmaster5000 avatar tuxmaster5000 commented on May 28, 2024

PR done:
receipt-print-hq/escpos-printer-db#87

from python-escpos.

belono avatar belono commented on May 28, 2024

Thank you!!

from python-escpos.

Related Issues (20)

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.