Commit Graph

161 Commits

Author SHA1 Message Date
Omer Akram 206822ac69 Enable Windows Support 2019-05-22 16:39:26 +05:00
Ramon Poca 2886075ce9 Fix initializer mess 2018-12-31 14:24:10 +01:00
Ramon Poca 73fff6291d Fix syntax 2018-12-31 13:57:53 +01:00
Ramon Poca 18c51358aa Add Win32Raw printer to available printers 2018-12-13 08:01:05 -08:00
Gerard Marull-Paretas 52719c0b7d Allow arbitrary USB args 2018-11-21 22:01:13 +01:00
Patrick Kanzler 6c94f88c24
improve platform independence (#296)
* add os.devnull for platform independence

fixes #288

* add test for soft_barcode

* open devnull as binary

* add version identifier to pickle
2018-05-15 01:03:07 +02:00
Patrick Kanzler 47b4d41b28
use package for tempdir
cherry-picked from 8494cca526 in #274
2018-05-13 18:52:39 +02:00
primax79 d085e5c467 parameter for implementation of nonnative qrcode (#289) 2018-05-13 18:42:41 +02:00
Thijs Triemstra 4390dc4a9c fix is_online() (#282)
* fix is_online

* fix sphinx formatting

* reword
2018-05-02 09:25:04 +02:00
Thijs Triemstra 6e09fd1e97 fix typo 2018-04-26 07:22:37 +02:00
Thijs Triemstra 100c6b5e89 fix typo (#279) 2018-02-07 22:17:18 +01:00
Christoph Heuel 26d72a69f0 Feature/clear content in dummy printer (#271)
Add Function to Dummy Printer for Clearing Buffer

If you are using the dummy printer, you may want to use the printer
again after sending the output to a physical printer.
This method empties the list of the output buffer.
2017-12-04 00:13:28 +01:00
reck 3c3dab95f5 raise exception when TypeError occurs in cashdraw (#268) 2017-12-03 23:21:29 +01:00
Patrick Kanzler 6b0b1371e5 fix layout in File-printer-section 2017-10-08 21:31:45 +02:00
Patrick Kanzler 44f01a212b fix docs failing due to pickle protocol in mixed env
When executing a tox-run a pickle file will be created. If the docs are
built after the py3 task, it will fail due to incompatible
pickle-protocols.
See https://stackoverflow.com/a/25843743/4244236 for reference.
2017-10-08 21:08:13 +02:00
Lucy Linder 456f5b7aa6 Feature/check barcodes (#255)
* add a method to check barcode code format

ensure that the code to print is compatible with the ESC/POS formats and
also automatically check this format before printing (barcode() method).

* rewrite test using pytest's parametrize functionality

* add test for the 'check' argument

* update authors list
2017-10-08 20:05:18 +02:00
Romain Porte b648cfd67f First attempt at centering images and QRs (#250)
This was tested on ZJ-5890 with success. By default centering is
deactivated for backward compatibility. Trying to center a QR code in
native mode will raise an exception as we do not know ATM if the native
rendering is centered by default or not.

* Added basic tests for center feature

* Check image size before centering
2017-08-31 09:25:35 +02:00
Sergio 50c627fbb0 Pickling capabilities for faster start up times. (#252)
On a RaspberryPi it's taking 10 seconds to simply run:

import escpos.printer

This change creates a pickle file that will load 20x faster. The
rationale is that the capabilities.json file doesn't change too often.

Also changed some imports for PEP8.
2017-08-31 09:07:26 +02:00
Patrick Kanzler 281eea125f fix abstract read-function
read does not need msg-parameter
2017-08-10 21:51:51 +02:00
Romain Porte b64b534394 Add methods for simpler newlines (#246) 2017-08-01 17:09:24 +02:00
Patrick Kanzler 81426ab6dc fix whitespace 2017-08-01 12:27:53 +02:00
Patrick Kanzler df1193ab35 implement read for Serial 2017-08-01 11:20:00 +02:00
Patrick Kanzler f8a2174108 fix typo 2017-07-27 23:06:59 +02:00
csoft2k 1f57b04974 Paper sensor querying command (#242)
The DLE EOT command allows querying the status of several features of
the printer.
Added to the online/offline status developed in #237, this commit adds a
paper sensor querying.

Tested with an Epson TM-T20II, which only has an end-paper sensor. The
near-end paper sensor should be tested with a compatible printer.
However, the implementation is quite straight-forward.
2017-07-27 23:05:50 +02:00
csoft2k 82c67aa646 Fix tabs behaviour (#238)
The changes done in this commit should help with the open issues:
#5, #27 and #161.
The old implementation lacked the NUL char at the end of the command, as
defined on the Epson ESC/POS Reference Guide (see
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=53
). Also, the horizontal tab control character (CTL_HT) shouldn't be
there.

This implementation allows setting up to 32 tabs with a given tab width.
Both values are checked to be in the valid ranges defined on the guide.
Also, the TabPosError exception text has been rewritten to define the
stated above.
2017-07-26 10:01:08 +02:00
Romain Porte 9e47ff2505 Added test for cut without feed, fixed raw code for it 2017-07-26 09:09:32 +02:00
Romain Porte 9bc3b30a60 Optional feed for cut (closes #213) 2017-07-26 09:09:32 +02:00
Romain Porte 5bd6dcf471 Ensure QR codes have a border large enough (#235)
*  Ensure QR codes have a border large enough
(The QR code spec requires a border at least 4*box_size thick but we can't
 just set border=16 because that results in a QR code more than 255px tall
 and I'm not yet ready to use fullimage() as a backend for it)
This fix was originally commited by Stephan Sokolow on 2014-05-22
* Let the user print stuff using qr example
* fix tests
2017-07-24 15:04:54 +02:00
csoft2k 89dfb6cf86 Added the DLE EOT querying command. (#237)
* Added the DLE EOT querying command.
Added a function to check whether the printer is online or not, as well
as a reading method for USB printers.
* Update AUTHORS
* Add entry to .mailmap
* currently USB only
2017-07-24 13:57:02 +02:00
TAHRI Ahmed efec3e508c Fix SerialException when trying to close device on __del__ without verifing if is actually opened. 2017-06-19 13:42:46 +02:00
Patrick Kanzler 83b426f5fd Merge pull request #222 from MicroJoe/software-barcode
First implementation of software barcode
2017-06-19 12:57:05 +02:00
Romain Porte c4dd4f2960 Added ImageWidthError and its implementation (#226)
* Added ImageWidthError and its implementation

* Added unit tests for ImageWidthError

* Parse max_width to int before compare
2017-05-23 15:13:28 +02:00
Romain Porte 22cf6ad00b Allow users to change impl for soft_barcode 2017-05-22 20:21:35 +02:00
TAHRI Ahmed 1f427953a8 Preliminary support of pos 'line display' printing 2017-05-22 00:40:40 +02:00
Romain Porte a6e1d0df00 Using booleans for handling text size 2017-05-21 22:50:07 +02:00
Romain Porte c0b4d03692 Updated documentation of set method 2017-05-21 22:50:07 +02:00
Romain Porte a16d6bde06 Refactor of the set method, with tests 2017-05-21 22:50:07 +02:00
Romain Porte 737cc3176e First implementation of software barcode
Actually the hardware barcode implementation is very specific and not
generic enough for just adding a `soft_render=True` argument to it. This
is a first work that can be improved with other commits, maybe for
merging this method in the `barcode` method after some cleanup.

The width, height and text_distance were set using empiric
print-and-retry tests so that the generated barcode looks nice to the
eye (and to the eye of an Android scanner tool.

!WARNING! Printing a barcode that is too large in width will result in
the printer to go crazy trying to print an image that is too large for
it. This may be fixed by raising an exception in the `image` method.
2017-05-16 20:56:27 +02:00
Romain Porte 4b04a5c425 Fixed bad format of :code: in documentation 2017-05-14 21:33:43 +02:00
Dmytro Katyukha a7ee11a78c Bugfix in `control` method. print_and_feed default `n=1` 2017-03-29 15:24:36 +02:00
Dmytro Katyukha 43e0a87a74 Updated capabilities data to new version 2017-03-29 15:24:36 +02:00
Dmytro Katyukha abbe32f845 Refactored `cut` method. added `print_and_feed` method 2017-03-29 15:24:25 +02:00
Dmytro Katyukha 29cc8baab7 Handle cases when fullCut or partCut not available 2017-03-29 15:24:25 +02:00
Sam Cheng a0ef820947 add support for an ESCPOS_CAPABILITIES_FILE environment variable. This is useful in situations where package structure is changed, such as using cx-freeze 2017-03-27 14:39:49 +02:00
Patrick Kanzler 3ee787e8b1
change license to MIT 2017-01-31 03:55:50 +01:00
Patrick Kanzler e92f00cdf3
fix AttributeError when executing close
When self.device is already None an AttributeError will occur.
This is relevant to #189.
2017-01-30 16:14:58 +01:00
Patrick Kanzler 337e8ee19e
add flake8-checks to travis 2017-01-30 02:29:08 +01:00
Patrick Kanzler 81028f9a35
refactor not ... in to ... not in ... 2017-01-30 02:16:22 +01:00
Patrick Kanzler fb18bb34cc
normalize imports 2017-01-30 02:15:40 +01:00
Patrick Kanzler 94a0f2b94b
normalize whitespace 2017-01-30 01:57:36 +01:00
Patrick Kanzler ce94a1fc18
normalize whitespace 2017-01-30 01:52:26 +01:00
Patrick Kanzler b4920aafe2
increase allowed line-length, fix whitespace in cli.py 2017-01-30 01:41:01 +01:00
Patrick Kanzler c48a0bee51
use not in instead of not ... in 2017-01-30 00:50:58 +01:00
Patrick Kanzler c2fc464c55
reformat PEP8 and similar issues 2017-01-30 00:10:14 +01:00
Patrick Kanzler e4a21e94fc
improve doc, improve codepage_tables.py 2017-01-29 23:36:33 +01:00
Patrick Kanzler e595bc2150
doc update methods and printers and use autodoc 2017-01-26 00:28:33 +01:00
Thijs Triemstra 7bf6a1791b Correct fragment_height documentation default (#198) 2017-01-25 23:56:06 +01:00
Michael 10c589ae8d swap default fragment height to 960 2016-10-04 14:01:26 +11:00
Patrick Kanzler cd38cdf74e Merge pull request #170 from miracle2k/text-encoding
Text encoding
2016-09-29 19:23:54 +02:00
Patrick Kanzler 1b2f509758
use jaconv instead of jcconv for japanese chars
jaconv is available for more Python-versions and seems to be more
professional. Apart from that I added jaconv to the test-requirements
but not the requirements. (If the katakana-stuff really works we can
later add it as a real dependency)
2016-09-27 20:31:39 +02:00
belono a82fefb301 Add support for custom cash drawer kick sequence 2016-09-15 22:54:35 +02:00
Michael Billington 7b68d97f5f test fixes - just case-changes to match code page names, seems to need 'future' pip module 2016-09-13 20:28:54 +10:00
Michael Billington 7a7ea23628 fixes to arguments for _encode_char 2016-09-11 21:08:04 +10:00
Michael Billington 83f926758c adjust order in _encode_char to prioritise ASCII; ' ' is used in the character list to flag characters with no known UTF-8 code, better not encode as these 2016-09-11 21:06:44 +10:00
Michael Billington 9a65945fcd re-work encoder to consult the capabilities database and use custom code pages or python encoder as necessary 2016-09-11 21:03:55 +10:00
Michael Billington d9a6960f07 efficiency improvements for backwards encoding 2016-09-11 20:21:30 +10:00
Michael Billington b5bf1125db reverse the lookup order to correct encoding issues 2016-09-11 17:17:22 +10:00
Michael Billington 2c8bc1180d Merge branch 'text-encoding' of https://github.com/miracle2k/python-escpos into miracle2k-text-encoding 2016-09-11 14:19:34 +10:00
Patrick Kanzler f467cacdd8
improve import capabilities from a submodule
The capabilities are now imported as a submodule from
mike42/escpos-printer-db
fixes #174
2016-09-02 17:13:38 +02:00
Michael Elsdörfer ddc93d7369 Fix byte format() on Python 3. 2016-08-30 18:06:34 +02:00
Michael Elsdörfer c3e3ec5808 Merge branch 'capabilities' into text-encoding 2016-08-30 18:02:40 +02:00
Michael Elsdörfer c850a726cb Fix docstring warnings from QuantifedCode. 2016-08-30 17:55:58 +02:00
Michael Elsdörfer 73ef8c4c0a Write as many characters as possible at once. 2016-08-30 17:39:26 +02:00
Michael Elsdörfer 9aa1335fd2 Improve codepage selection logic. 2016-08-30 17:13:05 +02:00
Michael Elsdörfer 2f89f3fe3a Port to current version of escpos-printer-db. 2016-08-30 17:08:27 +02:00
Michael Elsdörfer 40be69347c Merge branch 'capabilities' into text-encoding 2016-08-30 16:14:22 +02:00
Michael Elsdörfer 58ea206c36 Avoid mutable default argumet. 2016-08-30 16:13:38 +02:00
Michael Elsdörfer b37f4fc8cc Merge branch 'capabilities' into text-encoding 2016-08-30 13:36:53 +02:00
Michael Elsdörfer b92eeed50b Add tests for the profile. 2016-08-30 13:27:48 +02:00
Michael Elsdörfer ea7769f8b2 Merge remote-tracking branch 'origin/development' into capabilities 2016-08-30 13:04:17 +02:00
Michael Elsdörfer 5fa89ff685 Automatically choose correct barcode function.
Tests for barcode function.
2016-08-30 13:02:58 +02:00
Michael Elsdörfer a07f84a5bc Match the current printer-db format. 2016-08-30 12:26:09 +02:00
Michael Elsdörfer 216184f43f Rework capabilities format based on Mike's ideas. 2016-08-27 12:17:35 +02:00
Michael Elsdörfer c7864fd785 Largely rewrite the magic text encoding feature. 2016-08-27 11:28:52 +02:00
Michael Elsdörfer f6ce7e45da Merge branch 'capabilities' into text-encoding 2016-08-26 15:29:31 +02:00
Michael Elsdörfer 3fd1a3de5d A suggested format for defining the code pages. 2016-08-26 15:14:28 +02:00
Michael Elsdörfer 214aa0d363 Fix issue with manually setting the encoding. 2016-08-26 15:14:02 +02:00
Patrick Kanzler cf41069829 Merge branch 'linespacing' of git://github.com/miracle2k/python-escpos into miracle2k-linespacing
Conflicts:
	src/escpos/constants.py
2016-08-26 14:16:06 +02:00
Michael Elsdörfer 632a104219 Fix docstring warning. 2016-08-26 11:59:40 +02:00
Michael Elsdörfer 8b5bc9cf8a Make the Escpos class accept a profile.
This is now used for the block_text function.
2016-08-26 10:41:01 +02:00
Michael Elsdörfer a8574ad9d7 Support loading capabilites YAML into Python classes. 2016-08-26 10:41:01 +02:00
Michael Elsdörfer ed3077f00f Define a capability format in YAML. 2016-08-26 10:41:01 +02:00
Michael Elsdörfer 07d47765aa Allow linespacing reset. Make this the default. 2016-08-26 10:38:36 +02:00
Michael Elsdörfer 854b75be30 Support changing the line spacing. 2016-08-26 10:34:52 +02:00
Michael Elsdörfer df0c874f6e Add constants for sheet mode, colors. 2016-08-26 10:30:29 +02:00
Patrick Kanzler 798893caee
refactor access of private member _img of qrcode
Since version 2.5 python-qrcode allows the direct access of the
PIL-functions. (We require version 4 and above).
Thus, we can simply call qr_img.convert() without accessing the private
member.
This refactoring is identical in functionality.
2016-08-15 23:24:06 +02:00
Patrick Kanzler e8d91a6735
test add type-check for the qr-printing 2016-08-15 23:23:07 +02:00
Patrick Kanzler 340a47d2f6 Merge pull request #152 from python-escpos/fix/large-image-printing
Fix/large image printing
2016-08-07 12:22:25 +02:00
Patrick Kanzler 38f9835931
fix printing of CODE128
The control sequence {A or {B or {C can't be part of the qr code.
For this the user has to supply this sequence.
2016-08-02 15:39:31 +02:00
Patrick Kanzler 87a6647053 fix force-encoding REBASE (contains todos)
* fixed the code of forced-encoding in order to make it work
* extended unittest for forced-encoding
* fixed the constant for Katakana-encoding
2016-08-02 04:42:21 +02:00