Comments (12)
This is quite an interesting test file, thanks for posting it. It definitely shows some buggy behaviour.
I'll work a bit with this file and get back to you. It looks like it's mostly raster data, which we can't extract yet, but I can certainly make some improvements based on what you've posted here.
from escpos-tools.
from escpos-tools.
I seem to pretty much the same output get using generic text driver
from escpos-tools.
Working on this in a branch called 'bugfix/unrecognised-commands', should be more like this-
$ php esc2text.php tmp.bin -v
[DEBUG] SelectPeripheralDeviceCmd
[DEBUG] UnknownDataCmd
[DEBUG] UnknownDataCmd
[DEBUG] UnknownDataCmd
[DEBUG] UnknownCommandOneArg
[DEBUG] UnknownCommandOneArg
[DEBUG] SelectPaperEndSensorsCmd
[DEBUG] SelectDefaultLineSpacingCmd
[DEBUG] SelectInternationalCharacterSetCmd
[DEBUG] SelectCodeTableCmd
[DEBUG] EnableSmoothingCmd
[DEBUG] CommandTwoArgs
[DEBUG] PrintAndFeedCmd (LineBreak)
[DEBUG] PrintAndFeedCmd (LineBreak)
[DEBUG] SetAbsolutePrintPosCmd
[DEBUG] GraphicsLargeDataCmd
[DEBUG] GraphicsDataCmd
[DEBUG] PrintAndFeedCmd (LineBreak)
[DEBUG] PrintAndFeedCmd (LineBreak)
[DEBUG] PrintAndFeedCmd (LineBreak)
[DEBUG] SetAbsolutePrintPosCmd
[DEBUG] GraphicsLargeDataCmd
[DEBUG] GraphicsDataCmd
[DEBUG] PrintAndFeedCmd (LineBreak)
[DEBUG] FeedAndCutCmd
The receipt is certainly wrapped up as raster images, so you can't retrieve the content with this parser yet. Unpacking the content in thoseGraphicsLargeDataCmd
calls (responsible for all the gibberish before) will happen as part of issue #6.
from escpos-tools.
Do you know of any POS printer driver that doesn't do this ? I can always try use another driver, and see if the Epson wings it
from escpos-tools.
I directly generate the receipts using mike42/escpos-php library, then use raw printing to deliver the data.
I think the issue you were having is solved in the latest master
branch. Can you please try running your test file through the tools again to verify? You might just need to activate the imagick
extension if you don't have it yet.
Expect text file to be created with some whitespace only, and a list of commands on the terminal:
php escimages tmp.bin > tmp.txt
Expect two images of parts of the receipt to be written in pbm
format, with a copy of each in png
format as well-
php esc2text.php tmp.bin -v
Expect HTML file to be written-
php esc2html.php tmp.bin > tmp.html
This output should appear visually similar to the actual receipt:
from escpos-tools.
I've tried it now and have gotten the images.
Now is there any way we can go about extracting the text from those images without running each file through tesseract ?
from escpos-tools.
Yes, to extract text from images, you will need an OCR tool, since there's no extra data we can recover from the ESC/POS. If you need perfect output, you will need to train tesseract for the font being used.
It sounds like you are familiar with it, but for future readers, I'll point out that the PBM files can be scooped up in alphabetical order and OCR'ed directly, no need to waste CPU cycles with PNG compression or TIFF conversion.
# tesseract
sudo apt-get install tesseract-ocr imagemagick
rm *.pbm
php escimages.php input_files/tmp.bin
convert -append *.pbm pbm:- | tesseract - -
Also, am I able to include this sample file in the repository, under the MIT license, for regression testing purposes?
Note: Tried pdfsandwich
as a second option, was slow and the output was poor quality.
# pdfsandwich
sudo apt-get install pdfsandwich wkhtmltopdf
php esc2html.php input_files/tmp.bin > tmp.html
wkhtmltopdf --page-size A7 tmp.html tmp.pdf
pdfsandwich tmp.pdf
pdftotext -layout tmp_ocr.pdf
cat tmp_ocr.txt
from escpos-tools.
Closing this off, I believe this bug has now been resolved.
from escpos-tools.
I'm sorry for the late reply, i was busy on another task.
Yes you can include the sample file, no problem.
This issue is resolved yes, thanks 👍 💯
from escpos-tools.
Sorry to jump in here, but I am having the same problem with my test file.
When I do php escpos2text.php test.bin, I get the following output:
...
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command GS
WARNING: Unknown command DLE NUL
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command FS
WARNING: Unknown command ESC W
PuTTYWARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
WARNING: Unknown command ESC W
...
When I use: php escimages test.bin > test.txt, I get:
Could not open input file: escimages
The receipt is generated with the Seiko CAPD347 Driver, so the ESC/POS format should be correct ... but it looks different to the example provided.
from escpos-tools.
@mike42 I used: php esc2html.php ascii.bin > output.html
and i get a blank page with any text.
so what's the problem?
this is my file:
ascii.txt
from escpos-tools.
Related Issues (20)
- Print Margin on Top HOT 2
- Support for QR codes HOT 5
- How to gerate Invoice like this? Or how to add html in print view? HOT 2
- esc2html encoding HOT 3
- I get a blank page when I execute my file ascii.bin with php esc2html.php ascii.bin > output.html HOT 2
- Add support for user-defined character sets HOT 1
- esc2html output error HOT 2
- fopen(/tmp/test.bin): failed to open stream: No such file or directory HOT 1
- esc2html: Uncaught ImagickException: insufficient image data in file
- Composer support HOT 1
- Add Docker support HOT 1
- Unable to generate Barcode HOT 1
- Unable to generate with Esc2html HOT 3
- Composer issue : Failed to extract mike42/escpos-php HOT 1
- For those who need encoding, use it. HOT 1
- How to implement in laravel? HOT 1
- PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given HOT 1
- Encoded characters in decoded output
- there is no bigger BULLSHIT than your programm HOT 1
- Is PHP 8.2 Supported? I get this error after upgrading - Uncaught Error: Undefined constant "ReceiptPrintHq\EscposTools\Parser\Command\STDERR
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 escpos-tools.