def pdf(self, id): buffer = BytesIO() # Create the PDF object, using the BytesIO object as its "file." p = canvas.Canvas(buffer) # Draw things on the PDF. Here's where the PDF generation happens. # See the ReportLab documentation for the full list of functionality. p.drawString(100, 800, "Hello world.") barcode = createBarcodeDrawing('Code128', value=id, barHeight=10*mm, humanReadable=True) barcode.drawOn(p, 100, 700) # Close the PDF object cleanly. p.showPage() p.save() # Get the value of the BytesIO buffer and write it to the response. pdf_data = buffer.getvalue() buffer.close() return wrap_pdf_response(pdf_data, "boarding_pass.pdf")
def pdf(self, id): c.fulfilment_group = FulfilmentGroup.find_by_id(id, True) xml_s = render('/fulfilment_group/pdf.mako') xsl_f = app_globals.mako_lookup.get_template('/fulfilment_group/pdf.xsl').filename pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) filename = klf_info['event_shortname'] + '_' + str(c.fulfilment_group.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def pdf(self, id): c.fulfilment_group = FulfilmentGroup.find_by_id(id, True) xml_s = render('/fulfilment_group/pdf.mako') xsl_f = app_globals.mako_lookup.get_template('/fulfilment_group/pdf.xsl').filename pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) filename = Config.get('event_shortname') + '_' + str(c.fulfilment_group.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def pdf(self, id): if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())): # Raise a no_auth error h.auth.no_role() c.invoice = Invoice.find_by_id(id, True) xml_s = render('/invoice/pdf.mako') xsl_f = get_path('zk_root') + '/zkpylons/templates/invoice/pdf.xsl' pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) filename = Config.get('event_shortname') + '_' + str(c.invoice.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def pdf(self, id): if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())): # Raise a no_auth error h.auth.no_role() c.invoice = Invoice.find_by_id(id, True) xml_s = render('/invoice/pdf.mako') xsl_f = file_paths['zk_root'] + '/zkpylons/templates/invoice/pdf.xsl' pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) filename = lca_info['event_shortname'] + '_' + str(c.invoice.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def pdf(self, id): if not h.auth.authorized( h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key()) ): # Raise a no_auth error h.auth.no_role() c.invoice = Invoice.find_by_id(id, True) xml_s = render("/invoice/pdf.mako") xsl_f = file_paths["zk_root"] + "/zkpylons/templates/invoice/pdf.xsl" pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) filename = lca_info["event_shortname"] + "_" + str(c.invoice.id) + ".pdf" return pdfgen.wrap_pdf_response(pdf_data, filename)
def pdf(self, id): if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())): # Raise a no_auth error h.auth.no_role() c.fulfilment_group = FulfilmentGroup.find_by_id(id, True) xml_s = render('/fulfilment/boardingpass.mako') xsl_f = file_paths['zk_root'] + '/zkpylons/templates/fulfilment/boardingpass.xsl' pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) if c.fulfilment_group.person: filename = lca_info['event_shortname'] + '_' + str(c.fulfilment_group.person_id) + '.pdf' else: filename = lca_info['event_shortname'] + '_' + str(c.fulfilment_group.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def pdf(self, id): if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())): # Raise a no_auth error h.auth.no_role() c.invoice = Invoice.find_by_id(id, True) xml_s = render('/invoice/pdf.mako') template_path = file_paths['theme_templates'] + '/invoice/pdf.xsl' if(os.path.isfile(template_path)): xsl_f = template_path else: xsl_f = file_paths['zk_root'] + '/zkpylons/templates/invoice/pdf.xsl' pdf_data = pdfgen.generate_pdf(xml_s, xsl_f) filename = lca_info['event_shortname'] + '_' + str(c.invoice.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def badge_pdf(self, id): pdf_data = self._badge(id) filename = Config.get('event_shortname') + '_' + str( c.fulfilment.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def badge_pdf(self, id): pdf_data = self._badge(id) filename = klf_info['event_shortname'] + '_' + str(c.fulfilment.id) + '.pdf' return pdfgen.wrap_pdf_response(pdf_data, filename)
def badge_pdf(self, id): pdf_data = self._badge(id) filename = Config.get("event_shortname") + "_" + str(c.fulfilment.id) + ".pdf" return pdfgen.wrap_pdf_response(pdf_data, filename)