def main(argv): document = dsc_document("EPS Demo") page = document.page() canvas = page.canvas(margin=mm(18), border=True) eps = eps_image(canvas, open(sys.argv[1]), border=True, document_level=True) page.append(eps) fp = open(sys.argv[1] + ".ps", "w") document.write_to(fp) fp.close()
def my_document(ds): document = dsc_document() dir = dirname(__file__) if dir == "": dir = "." print("Loading background", file=debug) background = eps_image(document, open(dir + "/conditions_background.eps", 'rb')) print("Loading fonts", file=debug) italic = type1(open(pjoin(dir, "italic.pfb"), 'rb'), open(pjoin(dir, "italic.afm"), 'rb')) bold = type1(open(pjoin(dir, "bold.pfb"), 'rb'), open(pjoin(dir, "bold.afm"), 'rb')) bolditalic = type1(open(pjoin(dir, "bolditalic.pfb"), 'rb'), open(pjoin(dir, "bolditalic.afm"), 'rb')) # Define the relevant styles. h1 = style(font=bolditalic, font_size=9.2, color="0.98 0 0.48 0.63 setcmykcolor", margin_top=mm(2)) h2 = style(font=bolditalic, font_size=8, color="0 setgray", margin_top=mm(2)) description = style(font=italic, font_size=7, color="0 setgray", padding_top=2, padding_bottom=1, text_align="justify") tabelle_dunkel = style(font=italic, font_size=7, color="0 setgray", background_color="1 0.24 sub setgray", padding_top=2, padding_bottom=1, padding_right=2) tabelle_hell = style(font=italic, font_size=7, color="0 setgray", background_color="1 0.12 sub setgray", padding_top=2, padding_bottom=1, padding_right=2) # Create the divs print("Making db requests", file=debug) divs = [] pages = ds.select(schema.page, sql.order_by("rank")) tabcounter = 0 for page in pages: ds = [] ds.append(div(page.name, h1)) entries = page.entries.select(sql.order_by("rank")) for entry in entries: if entry.type == "caption": if entry.value1 is not None and entry.value1.strip() != "": ds.append(div(entry.value1, h2)) if entry.value2 is not None and entry.value2.strip() != "": ds.append(div(entry.value2, description)) elif entry.type == "info": if entry.value2 is None or entry.value2.strip() == "": ds.append(div(entry.value1, description)) else: cls = ( tabelle_dunkel, tabelle_hell, )[tabcounter%2] tabcounter += 1 ds.append(lr_div(entry.value1, entry.value2, cls)) divs.append(div_div(ds)) # layout print("Starting layout process", file=debug) layout(divs, new_page(document, background, italic)) return document
def __init__(self, filename): self.eps = eps_image(canvas.psg_canvas, open(filename + '.eps', 'rb'), document_level=True) self.height = eps.h() * self.scale self.width = eps.w() * self.scale
def __init__(self, filename): self.eps = eps_image(canvas.psg_canvas, open(filename + ".eps", "rb"), document_level=True) self.height = eps.h() * self.scale self.width = eps.w() * self.scale
def my_document(ds): document = dsc_document() dir = dirname(__file__) if dir == "": dir = "." print("Loading background", file=debug) background = eps_image(document, open(dir + "/conditions_background.eps", 'rb')) print("Loading fonts", file=debug) italic = type1(open(pjoin(dir, "italic.pfb"), 'rb'), open(pjoin(dir, "italic.afm"), 'rb')) bold = type1(open(pjoin(dir, "bold.pfb"), 'rb'), open(pjoin(dir, "bold.afm"), 'rb')) bolditalic = type1(open(pjoin(dir, "bolditalic.pfb"), 'rb'), open(pjoin(dir, "bolditalic.afm"), 'rb')) # Define the relevant styles. h1 = style(font=bolditalic, font_size=9.2, color="0.98 0 0.48 0.63 setcmykcolor", margin_top=mm(2)) h2 = style(font=bolditalic, font_size=8, color="0 setgray", margin_top=mm(2)) description = style(font=italic, font_size=7, color="0 setgray", padding_top=2, padding_bottom=1, text_align="justify") tabelle_dunkel = style(font=italic, font_size=7, color="0 setgray", background_color="1 0.24 sub setgray", padding_top=2, padding_bottom=1, padding_right=2) tabelle_hell = style(font=italic, font_size=7, color="0 setgray", background_color="1 0.12 sub setgray", padding_top=2, padding_bottom=1, padding_right=2) # Create the divs print("Making db requests", file=debug) divs = [] pages = ds.select(schema.page, sql.order_by("rank")) tabcounter = 0 for page in pages: ds = [] ds.append(div(page.name, h1)) entries = page.entries.select(sql.order_by("rank")) for entry in entries: if entry.type == "caption": if entry.value1 is not None and entry.value1.strip() != "": ds.append(div(entry.value1, h2)) if entry.value2 is not None and entry.value2.strip() != "": ds.append(div(entry.value2, description)) elif entry.type == "info": if entry.value2 is None or entry.value2.strip() == "": ds.append(div(entry.value1, description)) else: cls = ( tabelle_dunkel, tabelle_hell, )[tabcounter % 2] tabcounter += 1 ds.append(lr_div(entry.value1, entry.value2, cls)) divs.append(div_div(ds)) # layout print("Starting layout process", file=debug) layout(divs, new_page(document, background, italic)) return document