adding normal and big printing features
This commit is contained in:
parent
4069170f3a
commit
f17663ec09
@ -51,14 +51,21 @@ def index():
|
|||||||
|
|
||||||
@APP.route('/print/', methods=['GET', 'POST'])
|
@APP.route('/print/', methods=['GET', 'POST'])
|
||||||
def print():
|
def print():
|
||||||
txt = request.args.get('printing', '')
|
txt_normal = request.args.get('normal', '')
|
||||||
|
txt_big = request.args.get('big', '')
|
||||||
img = request.files.get('img')
|
img = request.files.get('img')
|
||||||
|
|
||||||
if txt:
|
if txt_normal:
|
||||||
source = 'TeleVex'
|
source = 'TeleVex'
|
||||||
txt, date = televex.preprocess(txt, type='txt')
|
txt, date = televex.preprocess(txt_normal, type='txt')
|
||||||
televex.update_db(db, db_path, txt, source, date)
|
televex.update_db(db, db_path, txt_normal, source, date)
|
||||||
televex.print_now(txt, lp=lp, type='txt')
|
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'))
|
return flask.redirect(flask.url_for('print'))
|
||||||
elif img:
|
elif img:
|
||||||
source = 'TeleVex'
|
source = 'TeleVex'
|
||||||
|
@ -21,3 +21,23 @@ div.msg pre{
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
white-space: pre-wrap;
|
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;
|
||||||
|
}
|
@ -13,12 +13,20 @@
|
|||||||
<div id="print">
|
<div id="print">
|
||||||
<h2>Plain Text Printing Point (ASCII only)</h2>
|
<h2>Plain Text Printing Point (ASCII only)</h2>
|
||||||
<form action="" method="GET">
|
<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>
|
||||||
<br>
|
<br>
|
||||||
<input class="submit" type="submit" value="print"/>
|
<input class="submit" type="submit" value="print"/>
|
||||||
</form>
|
</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>
|
<br>
|
||||||
|
|
||||||
<h2>Image printing access point (png, jpg, gif)</h2>
|
<h2>Image printing access point (png, jpg, gif)</h2>
|
||||||
|
@ -74,7 +74,7 @@ def update_db(db, db_path, post, source, date, type=None):
|
|||||||
|
|
||||||
return already_in_db
|
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
|
# configure the printouts
|
||||||
if lp:
|
if lp:
|
||||||
if type == 'rss':
|
if type == 'rss':
|
||||||
@ -86,10 +86,10 @@ def print_now(output, lp=None, type=None):
|
|||||||
)
|
)
|
||||||
lp.line_spacing(spacing=75) # 0 - 255
|
lp.line_spacing(spacing=75) # 0 - 255
|
||||||
columns = 12 # b 8 8
|
columns = 12 # b 8 8
|
||||||
elif type == "txt":
|
elif size == "normal":
|
||||||
lp.set(
|
lp.set(
|
||||||
align='left',
|
align='left',
|
||||||
font='b',
|
font='a',
|
||||||
text_type='normal', # B, U, U2, BU, BU2, NORMAL
|
text_type='normal', # B, U, U2, BU, BU2, NORMAL
|
||||||
width=1, # 1-8
|
width=1, # 1-8
|
||||||
height=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
|
lp.line_spacing(spacing=65) # 0 - 255
|
||||||
# columns = 48 # a 1 1
|
# 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':
|
elif type == 'img':
|
||||||
lp.line_spacing(spacing=50) # 0 - 255
|
lp.line_spacing(spacing=50) # 0 - 255
|
||||||
|
|
||||||
# print
|
# print
|
||||||
if lp:
|
if lp:
|
||||||
if type == 'txt' or type == 'rss':
|
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.block_text(output, columns=columns) # columns=line width
|
||||||
lp.cut()
|
lp.cut()
|
||||||
elif type == 'img':
|
elif type == 'img':
|
||||||
|
Loading…
Reference in New Issue
Block a user