From f17663ec092fad059ffa8d2d9f4ffdc6a69dec90 Mon Sep 17 00:00:00 2001 From: manetta Date: Fri, 19 Mar 2021 15:43:59 +0100 Subject: [PATCH] adding normal and big printing features --- print/start.py | 17 ++++++++++++----- print/static/stylesheet.css | 20 ++++++++++++++++++++ print/templates/print.html | 10 +++++++++- print/tools/televex/televex.py | 22 ++++++++++++++++++---- 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/print/start.py b/print/start.py index 111bf3a..db30c1c 100644 --- a/print/start.py +++ b/print/start.py @@ -51,14 +51,21 @@ def index(): @APP.route('/print/', methods=['GET', 'POST']) def print(): - txt = request.args.get('printing', '') + txt_normal = request.args.get('normal', '') + txt_big = request.args.get('big', '') img = request.files.get('img') - if txt: + if txt_normal: source = 'TeleVex' - txt, date = televex.preprocess(txt, type='txt') - televex.update_db(db, db_path, txt, source, date) - televex.print_now(txt, lp=lp, type='txt') + txt, date = televex.preprocess(txt_normal, type='txt') + televex.update_db(db, db_path, txt_normal, source, date) + televex.print_now(txt_normal, lp=lp, type='txt', size='normal') + return flask.redirect(flask.url_for('print')) + elif txt_big: + source = 'TeleVex' + txt_big, date = televex.preprocess(txt_big, type='txt') + televex.update_db(db, db_path, txt_big, source, date) + televex.print_now(txt_big, lp=lp, type='txt', size='big') return flask.redirect(flask.url_for('print')) elif img: source = 'TeleVex' diff --git a/print/static/stylesheet.css b/print/static/stylesheet.css index 1ec8f8b..c69cad0 100644 --- a/print/static/stylesheet.css +++ b/print/static/stylesheet.css @@ -21,3 +21,23 @@ div.msg pre{ word-break: break-word; white-space: pre-wrap; } +hr{ + margin: 4em 0; +} +form{ + display: inline-block; +} +textarea{ + height: 600px; + border: 1px solid black; +} +textarea#normal{ + line-height: 1.5; +} +textarea#big{ + background-color: black; + color: white; + font-size: 72px; + line-height: 1; + word-break: break-all; +} \ No newline at end of file diff --git a/print/templates/print.html b/print/templates/print.html index d63d2ec..5cea897 100644 --- a/print/templates/print.html +++ b/print/templates/print.html @@ -13,12 +13,20 @@

Plain Text Printing Point (ASCII only)

- +

+
+ +
+
+ +
+ +

Image printing access point (png, jpg, gif)

diff --git a/print/tools/televex/televex.py b/print/tools/televex/televex.py index df34bac..ca7e35b 100644 --- a/print/tools/televex/televex.py +++ b/print/tools/televex/televex.py @@ -74,7 +74,7 @@ def update_db(db, db_path, post, source, date, type=None): return already_in_db -def print_now(output, lp=None, type=None): +def print_now(output, lp=None, type=None, size=None): # configure the printouts if lp: if type == 'rss': @@ -86,10 +86,10 @@ def print_now(output, lp=None, type=None): ) lp.line_spacing(spacing=75) # 0 - 255 columns = 12 # b 8 8 - elif type == "txt": + elif size == "normal": lp.set( align='left', - font='b', + font='a', text_type='normal', # B, U, U2, BU, BU2, NORMAL width=1, # 1-8 height=1, # 1-8 @@ -100,13 +100,27 @@ def print_now(output, lp=None, type=None): ) lp.line_spacing(spacing=65) # 0 - 255 # columns = 48 # a 1 1 - columns = 65 # b 1 1 + columns = 48 # b 1 1 + elif size == "big": + lp.set( + align='left', + font='b', + text_type='normal', # B, U, U2, BU, BU2, NORMAL + width=8, # 1-8 + height=8, # 1-8 + invert=True + ) + lp.line_spacing(spacing=75) # 0 - 255 + # columns = 48 # a 1 1 + columns = 8 # b 1 1 elif type == 'img': lp.line_spacing(spacing=50) # 0 - 255 # print if lp: if type == 'txt' or type == 'rss': + # lp._raw(b'\x1b'+b'\x52'+b'\x32') # switch to code table, see http://docshare03.docshare.tips/files/24677/246773902.pdf for more info (does not work) + # lp.magic.force_encoding('CP858') # does not work lp.block_text(output, columns=columns) # columns=line width lp.cut() elif type == 'img':