|
|
|
@ -314,34 +314,15 @@ class Bureau(object):
|
|
|
|
|
def print_full(self, template, **kwargs):
|
|
|
|
|
"""print a full page (A4) document """
|
|
|
|
|
# TODO: look up the printer LPR name / allow multiple printers/non-default
|
|
|
|
|
|
|
|
|
|
# lpname = kwargs.get("printer", "default")
|
|
|
|
|
|
|
|
|
|
#htmlfile, htmlpath = tempfile.mkstemp(".html")
|
|
|
|
|
#htmlfile = os.fdopen(htmlfile, "w")
|
|
|
|
|
# run template with kwargs
|
|
|
|
|
templfile = os.path.join(self.mdir, template)
|
|
|
|
|
self.log.debug("printing with template: %s", templfile)
|
|
|
|
|
templ = Template(filename=templfile, strict_undefined=True)
|
|
|
|
|
#htmlfile.write(templ.render_unicode(**kwargs))
|
|
|
|
|
#htmlfile.close()
|
|
|
|
|
#.encode('utf-8',
|
|
|
|
|
# 'replace'))
|
|
|
|
|
|
|
|
|
|
# texfile, texfilepath = tempfile.mkstemp(".tex")
|
|
|
|
|
# texfile.write(templ.render_unicode(
|
|
|
|
|
# **kwargs).encode('utf-8', 'replace'))
|
|
|
|
|
|
|
|
|
|
# texdir = os.path.dirname(texfilepath)
|
|
|
|
|
|
|
|
|
|
# subprocess.call("cd " + texdir + "; xelatex " + texfilepath)
|
|
|
|
|
|
|
|
|
|
# TODO: make paper size a config variable
|
|
|
|
|
pdfpath = tempfile.mkstemp(".pdf")[1]
|
|
|
|
|
self.log.debug("rendering to: " + pdfpath)
|
|
|
|
|
weasyprint.HTML(string=templ.render_unicode(**kwargs)).write_pdf(pdfpath)
|
|
|
|
|
#subprocess.call(self.html2pdf + htmlpath + " " + pdfpath +
|
|
|
|
|
# " A4 1920px", shell=True)
|
|
|
|
|
subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper " + pdfpath, shell=True)
|
|
|
|
|
|
|
|
|
|
# TODO: make this asynchronous
|
|
|
|
|