adding normal and big printing features

This commit is contained in:
manetta 2021-03-19 15:43:59 +01:00
parent 4069170f3a
commit f17663ec09
4 changed files with 59 additions and 10 deletions

View File

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

View File

@ -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;
}

View File

@ -13,12 +13,20 @@
<div id="print">
<h2>Plain Text Printing Point (ASCII only)</h2>
<form action="" method="GET">
<textarea name="printing" cols="42" rows="30">{{ plaintext }}</textarea>
<textarea id="normal" name="normal" cols="48" rows="30">{{ plaintext }}</textarea>
<br>
<br>
<input class="submit" type="submit" value="print"/>
</form>
<form action="" method="GET">
<textarea id="big" name="big" cols="8" rows="10">{{ plaintext }}</textarea>
<br>
<br>
<input class="submit" type="submit" value="print"/>
</form>
<br>
<br>
<h2>Image printing access point (png, jpg, gif)</h2>

View File

@ -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':