Git Product home page Git Product logo

Comments (12)

mike42 avatar mike42 commented on August 21, 2024

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.

A-Rotsaert avatar A-Rotsaert commented on August 21, 2024

from escpos-tools.

KlustoR avatar KlustoR commented on August 21, 2024

I seem to pretty much the same output get using generic text driver

from escpos-tools.

mike42 avatar mike42 commented on August 21, 2024

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.

KlustoR avatar KlustoR commented on August 21, 2024

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.

mike42 avatar mike42 commented on August 21, 2024

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:

screenshot from 2017-05-26 23-18-20

from escpos-tools.

KlustoR avatar KlustoR commented on August 21, 2024

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.

mike42 avatar mike42 commented on August 21, 2024

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.

mike42 avatar mike42 commented on August 21, 2024

Closing this off, I believe this bug has now been resolved.

from escpos-tools.

KlustoR avatar KlustoR commented on August 21, 2024

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.

nsatech avatar nsatech commented on August 21, 2024

test.zip

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.

zarafati avatar zarafati commented on August 21, 2024

@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)

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.