Comments (29)
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.
Yes the value in the profile was the problem.
Now the QR code are correct aligned:
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.
@belono it will result in:
"1A21C1E01P0https://de.wikipedia.o"
from python-escpos.
@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.
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.
@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.
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.
Hi, could you please try this with the most recent v3.0?
from python-escpos.
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.
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.
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.
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.
Could you please try the same with the Dummy printer and then give us the content of Dummy.output?
from python-escpos.
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.
@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.
Now the printer prints an QR code, but it is complete miss formatted.
from python-escpos.
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.
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.
from python-escpos.
@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.
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.
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.
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)
from python-escpos.
And adding:
"high_density_horizontal": False,
will result in:
from python-escpos.
Are there any new code that I can test?
from python-escpos.
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.
Yes now it looks much better. So now the center option looks like broken to or?
from python-escpos.
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.
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.
PR done:
receipt-print-hq/escpos-printer-db#87
from python-escpos.
Thank you!!
from python-escpos.
Related Issues (20)
- Text size not working (width and height) HOT 11
- Barcode not printed HOT 4
- Introduce IntEnum or similar for printer states
- Usb printer not working on web Application HOT 2
- Printer not found on web application HOT 1
- Font switching not working. HOT 3
- is_online() fails with raise NotImplementedError()
- Full cut not working on Epson TM-T20III HOT 2
- 'usb timeout error' when used on a raspberry pi 3 with a cheap POS-58 thermal printer HOT 5
- ImportError: cannot import name 'DeviceNotFoundError' from 'escpos.exceptions' HOT 2
- usb.core.USBError: [Errno 5] Input/Output Error` HOT 1
- EPSON TM-m30III randomly fails to print images HOT 1
- Arabic Text not printing correctly HOT 2
- Tabbed text HOT 8
- windows Invalid endpoint address HOT 1
- Printer Emulator Connection Issue HOT 6
- How to print big5 charcode HOT 1
- CLI not working for CupsPrinter, LP and Win32Raw connectors
- Print to a bluetooth device via rfcomm and printer.File() HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-escpos.