def create_pdf(togen, template_page, pos, dat): "Create the pdf, stream api" document = BaseDocTemplate(togen) page = MyPage(template_page, name='background') document.addPageTemplates([page]) elements = [NextPageTemplate('background')] # may add flowables to element here # add absolute content for posname in dat: if posname.startswith("_"): # ignore extra info continue if posname not in pos: raise Exception("%s does not have a position" % posname) tup = pos[posname] x, y = tup[0], tup[1] width = tup[2] if len(tup)>2 else PAGE_WIDTH style = tup[3] if len(tup)>3 else DEFAULT_STYLE data = dat[posname] if type(data) in (str, unicode): page.addAbsParagraph(data, x, y, width, style) else: page.addAbsPrimitive(data, x, y, width) # don't need no style # create page document.multiBuild(elements)
def create_pdf(togen, template_page, pos, dat): "Create the pdf, stream api" document = BaseDocTemplate(togen) page = MyPage(template_page, name='background') document.addPageTemplates([page]) elements = [NextPageTemplate('background')] # may add flowables to element here # add absolute content for posname in dat: if posname.startswith("_"): # ignore extra info continue if posname not in pos: raise Exception("%s does not have a position" % posname) tup = pos[posname] x, y = tup[0], tup[1] width = tup[2] if len(tup) > 2 else PAGE_WIDTH style = tup[3] if len(tup) > 3 else DEFAULT_STYLE data = dat[posname] if type(data) in (str, unicode): page.addAbsParagraph(data, x, y, width, style) else: page.addAbsPrimitive(data, x, y, width) # don't need no style # create page document.multiBuild(elements)
def _callParentBuild(self, story): """ call the parent multibuild. to pass the drawing more than once """ BaseDocTemplate.multiBuild(self, story)
def _callParentBuild(self, story): """ call the parent multibuild. to pass the drawing more than once """ BaseDocTemplate.multiBuild(self, story)