|
|
@ -354,20 +354,19 @@ class Bureau(object):
|
|
|
|
# TODO: make paper size a config variable
|
|
|
|
# TODO: make paper size a config variable
|
|
|
|
pdfpath = tempfile.mkstemp(".pdf")[1]
|
|
|
|
pdfpath = tempfile.mkstemp(".pdf")[1]
|
|
|
|
self.log.debug("rendering to: " + pdfpath)
|
|
|
|
self.log.debug("rendering to: " + pdfpath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# manually add local fonts
|
|
|
|
fontconfig = FontConfiguration()
|
|
|
|
fontconfig = FontConfiguration()
|
|
|
|
fontsdir = os.path.join(self.mdir, "fonts")
|
|
|
|
fontsdir = os.path.join(self.mdir, "fonts")
|
|
|
|
self.log.debug(fontsdir)
|
|
|
|
fontlist = []
|
|
|
|
for font in glob.glob(fontsdir + "/*.otf"):
|
|
|
|
for font in glob.glob(fontsdir + "/*.otf"):
|
|
|
|
fdict = {}
|
|
|
|
fontlist.append(("local", "file://" + font))
|
|
|
|
fdict["src"] = ("local", "file://" + font)
|
|
|
|
|
|
|
|
self.log.debug("adding font " + str(fdict))
|
|
|
|
self.log.debug("adding font " + str(fdict))
|
|
|
|
fontconfig.add_font_face(fdict,
|
|
|
|
|
|
|
|
weasyprint.default_url_fetcher)
|
|
|
|
|
|
|
|
for font in glob.glob(fontsdir + "/*.ttf"):
|
|
|
|
for font in glob.glob(fontsdir + "/*.ttf"):
|
|
|
|
fdict = {}
|
|
|
|
fontlist.append(("local", "file://" + font))
|
|
|
|
fdict["src"] = ("local", "file://" + font)
|
|
|
|
|
|
|
|
self.log.debug("adding font " + str(fdict))
|
|
|
|
self.log.debug("adding font " + str(fdict))
|
|
|
|
fontconfig.add_font_face(fdict,
|
|
|
|
fdict["src"] = fontlist
|
|
|
|
|
|
|
|
fontconfig.add_font_face(fdict,
|
|
|
|
weasyprint.default_url_fetcher)
|
|
|
|
weasyprint.default_url_fetcher)
|
|
|
|
weasyprint.HTML(string=templ.render_unicode(**kwargs)).write_pdf(pdfpath, font_config=fontconfig)
|
|
|
|
weasyprint.HTML(string=templ.render_unicode(**kwargs)).write_pdf(pdfpath, font_config=fontconfig)
|
|
|
|
subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper " + pdfpath, shell=True)
|
|
|
|
subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper " + pdfpath, shell=True)
|
|
|
|