Ejemplo n.º 1
0
    def create_pdf(self):
        pdf = StringIO.StringIO()

        doc = SimpleDocTemplate(pdf)
        doc.leftMargin = 31
        doc.rightMargin = 31
        doc.topMargin = 390
        doc.bottomMargin = 110

        story = []
        order_items = [["Artikelnr.", "Name", "Menge", "Preis", "Summe"]]
        for item in self.order.items.all():
            amount = str(item.amount) + " " + item.product.unit
            price = currency(item.product_price_gross)
            total = currency(item.price_gross)
            order_items.append(
                [item.product.sku, item.product_name, amount, price, total])

        order_items_table = Table(order_items, (80, 238, 60, 70, 70))
        order_items_table.setStyle(dn_order_items_style)

        story.append(order_items_table)
        story.append(Spacer(1, 40))

        # END
        story.append(Paragraph(getattr(settings, "DN_END"), styleN))

        doc.build(story, onFirstPage=self.page, onLaterPages=self.page)
        pdf.seek(0)
        return pdf
Ejemplo n.º 2
0
def go():
    doc = SimpleDocTemplate("phello.pdf")
    doc.pagesize = (6 * inch, 4 * inch)
    doc.leftMargin = 0.25 * inch
    doc.bottommargin = 0.25 * inch
    # doc.height=3.75*inch
    # doc.width=5.75*inch
    doc.height = 4 * inch
    doc.width = 6 * inch
    Story = []
    style = styles["Normal"]
    for i in range(3):
        bogustext = ("This is Paragraph number %s. " % i) * 2
        p = Paragraph(bogustext, style)
        # p = Paragraph(bogustext)
        Story.append(p)
        # Story.append(Spacer(1,0.2*inch))
    l = []
    for x in range(3):
        l.append(["row%i col1" % x, "row%i col2" % i])
    Story.append(Table(l))
    Story.append(Paragraph("Hello", styles["Title"]))
    # Story.append(Paragraph("Hello"))
    #doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
    doc.build(Story)
Ejemplo n.º 3
0
    def __init__(self, report: InterestTransferListReport, year: int, today: str):
        self.buffer = io.BytesIO()
        story = []

        styles = getSampleStyleSheet()
        styleH1 = styles['Heading2']
        styleH2 = styles['Heading3']
        styleB = copy.deepcopy(styles['Normal'])
        styleB.spaceAfter = 0.1*cm
        styleB.fontName = 'Helvetica-Bold'

        doc = SimpleDocTemplate(self.buffer, pagesize=A4)
        doc.leftMargin = 1*cm
        doc.rightMargin = 1*cm
        doc.topMargin = 1*cm
        doc.bottomMargin = 1*cm

        story.append(Paragraph(f"Zinsen für das Jahr {year}", styleH1))
        for data in report.per_contract_data:
            story.append(Paragraph(f"Direktkreditvertrag Nr. {data.contract.number}, {data.contract.contact}", styleH2))
            story.append(Paragraph(f"Kontostand {today}: {euro(data.contract.balance)}", styleB))
            story.append(Paragraph(f"Zinsberechung {year}:", styleB))
            story.append(interest_year_table(data.interest_rows))
            story.append(Spacer(1, 0.1*cm))
            story.append(Paragraph(f"Zinsen {year}: {euro(data.interest)}", styleB))

        story.append(Spacer(1, 0.5*cm))
        story.append(Paragraph(f"SUMME ZINSEN {year}: {euro(report.sum_interest)}", styleB))

        doc.build(story)
        self.buffer.seek(0)
Ejemplo n.º 4
0
    def create_pdf(self):
        pdf = StringIO.StringIO()

        doc = SimpleDocTemplate(pdf)
        doc.leftMargin=31
        doc.rightMargin=31
        doc.topMargin=390
        doc.bottomMargin=110

        story = []
        order_items = [["Artikelnr.", "Name", "Menge", "Preis", "Summe"]]
        for item in self.order.items.all():
            amount = str(item.amount) + " " + item.product.unit
            price = currency(item.product_price_gross)
            total = currency(item.price_gross)
            order_items.append([item.product.sku, item.product_name, amount, price, total])

        order_items_table = Table(order_items, (80, 238, 60, 70, 70))
        order_items_table.setStyle(dn_order_items_style)

        story.append(order_items_table)
        story.append(Spacer(1, 40))

        # END
        story.append(Paragraph(getattr(settings, "DN_END"), styleN))

        doc.build(story, onFirstPage=self.page, onLaterPages=self.page)
        pdf.seek(0)
        return pdf
Ejemplo n.º 5
0
    def create_pdf(self):
        pdf = StringIO.StringIO()

        doc = SimpleDocTemplate(pdf)
        doc.leftMargin=31
        doc.rightMargin=31
        doc.topMargin=390
        doc.bottomMargin=110

        story = []
        order_items = [["Artikelnr.", "Name", "Menge", "Preis", "Summe"]]
        for item in self.order.items.all():
            # Amount
            amount = str(item.amount)
            if item.product.unit:
                amount += " " + item.product.unit
            if item.product.active_packing_unit:
                amount += "\n(" + str(packages(item)) + " " + item.product.packing_unit_unit + ")"
            # Name
            item_name = item.product_name
            for property in item.product.get_displayed_properties():
                item_name += "\n" + property["title"] + ": " + property["value"] + " " + property["unit"]
            for property in item.product.get_variant_properties():
                item_name += "\n" + property["title"] + ": " + property["value"] + " " + property["unit"]
            if item.product.is_configurable_product():
                for property in item.get_properties():
                    item_name += "\n" + property["title"] + ": " + property["value"] + property["unit"] + " " + property["price"]
            price = currency(item.product_price_gross)
            if item.product.price_unit:
                price += " / " + item.product.price_unit
            total = currency(item.price_gross)
            order_items.append([item.product.sku, item_name, amount, price, total])

        if self.order.voucher_number:
            order_items.append(["", "Voucher", "1", currency(self.order.voucher_price), currency(self.order.voucher_price)])

        order_items.append(["", "Versandart (" + self.order.shipping_method.name + ")", "1", currency(self.order.shipping_price), currency(self.order.shipping_price)])
        order_items.append(["", "Zahlungsweise (" + self.order.payment_method.name + ")", "1", currency(self.order.payment_price), currency(self.order.payment_price)])

        order_items.append(["", "", "", "Summe", currency(self.order.price)])
        order_items.append(["", "", "", "Inkl. MwSt", currency(self.order.tax)])

        order_items_table = Table(order_items, (80, 238, 60, 70, 70))
        order_items_table.setStyle(in_order_items_style)

        story.append(order_items_table)
        story.append(Spacer(1, 40))

        # END
        story.append(Paragraph(getattr(settings, "IN_END"), styleN))

        doc.build(story, onFirstPage=self.page, onLaterPages=self.page)
        pdf.seek(0)
        return pdf
Ejemplo n.º 6
0
def get_document(args, rightMargin=2.5*mm, leftMargin = 2.5*mm, topMargin = 2.5*mm, bottomMargin = 2.5*mm):
    save_path = f'{args.title}.pdf'
    doc = SimpleDocTemplate(save_path)
    doc.title = args.title

    doc.rightMargin = rightMargin
    doc.leftMargin = leftMargin
    doc.topMargin = topMargin
    doc.bottomMargin = bottomMargin
    doc.width = A4[0] - (doc.rightMargin + doc.leftMargin)
    doc.height = A4[1] - (doc.topMargin + doc.bottomMargin)

    return doc
Ejemplo n.º 7
0
def start_pdf(mdata):
	global doc, elements, dwidth, dheight

	pdf_file = os.path.join(PDF_DIR, mdata['title'] + '.pdf')
	doc = SimpleDocTemplate(pdf_file, pagesize=letter)
	elements = []
	dwidth, dheight = letter

	# margins
	doc.topMargin = TOP_MARGIN
	doc.leftMargin = LEFT_MARGIN
	doc.bottomMargin = TOP_MARGIN
	doc.rightMargin = LEFT_MARGIN
Ejemplo n.º 8
0
def go():
	doc = SimpleDocTemplate(f'cv_{LANGUAGE}.pdf')
	doc.leftMargin = LEFT_BAR + LEFT_BAR_MARGIN
	doc.rightMargin = 20
	doc.topMargin = 0.5 * cm
	Story = []
	style = styles['Normal']
	style.__dict__['justifyBreaks'] = 0
	style.__dict__['autoLeading'] = 'max'
	style.__dict__['alignment'] = 4
	style.__dict__['spaceAfter'] = 6
	style.refresh()
	for entry in parsedCV:
		p = Paragraph(entry, style)
		Story.append(p)
		#Story.append(Spacer(1,2*cm))
	doc.build(Story, onFirstPage=firstPage, onLaterPages=laterPages)
Ejemplo n.º 9
0
def make_test(exam):

    # Set up custom fonts
    register_true_type_font()

    answers = False


    # Set up Doc properties
    styles = getSampleStyleSheet()
    
    if answers == True:
        doc = SimpleDocTemplate(f"exams/export/2021 {exam.name} ANSWERS.pdf",pagesize=letter)  
    else:
        doc = SimpleDocTemplate(f"exams/export/2021 {exam.name} Test.pdf",pagesize=letter)   

    doc_properties.Title = f"2021 {exam.name} Written Test"
    doc_properties.pageinfo = f"2021 {exam.name} Written Test"

    Story = [Spacer(1,.5*inch)]    
    style = styles["Normal"]   

    doc.leftMargin = 0.75 * inch
    doc.rightMargin = 0.75 * inch
    doc.title = '2021 State Conference Test'
    doc.auther = 'Pennsylvania TSA'

    for num, question, a, b, c, d, correct in zip(exam.numbers, exam.question, exam.choice_a, exam.choice_b, exam.choice_c, exam.choice_d, exam.correct):
        Story.append(IntegrateQuestions(num, question, a, b, c, d, correct, answers))
        Story.append(Spacer(0, 0.25*inch))

    # Append post-table text, if any
    Story.append(Spacer(0, 0.2*inch))  
    post_text = "This is the end of the test. Please submit your answer sheet."        
    p = Paragraph(post_text, style)
    Story.append(p)        

    # Finally, generate and save the PDF
    doc.build(Story, onFirstPage=FirstPage, onLaterPages=LaterPages)
Ejemplo n.º 10
0
def go():
    doc = SimpleDocTemplate("phello.pdf")
    doc.pagesize=(6*inch,4*inch)
    doc.leftMargin=0.25*inch
    doc.bottommargin=0.25*inch
    #doc.height=3.75*inch
    #doc.width=5.75*inch
    doc.height=4*inch
    doc.width=6*inch
    Story = []
    style = styles["Normal"]
    for i in range(3):
        bogustext = ("This is Paragraph number %s. " % i) *2
        p = Paragraph(bogustext, style)
        Story.append(p)
        #Story.append(Spacer(1,0.2*inch))
    l=[]
    for x in range(3):
        l.append(["row%i col1" % x, "row%i col2" % i])
    Story.append(Table(l))
    Story.append(Paragraph("Hello", styles["Title"]))
    #doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
    doc.build(Story)
Ejemplo n.º 11
0
    def create_pdf(self):
        pdf = StringIO.StringIO()

        doc = SimpleDocTemplate(pdf)
        doc.leftMargin = 31
        doc.rightMargin = 31
        doc.topMargin = 390
        doc.bottomMargin = 110

        story = []
        order_items = [["Artikelnr.", "Name", "Menge", "Preis", "Summe"]]
        for item in self.order.items.all():
            # Amount
            amount = str(item.amount)
            if item.product.unit:
                amount += " " + item.product.unit
            if item.product.active_packing_unit:
                amount += "\n(" + str(packages(
                    item)) + " " + item.product.packing_unit_unit + ")"
            # Name
            item_name = item.product_name
            for property in item.product.get_displayed_properties():
                item_name += "\n" + property["title"] + ": " + property[
                    "value"] + " " + property["unit"]
            for property in item.product.get_variant_properties():
                item_name += "\n" + property["title"] + ": " + property[
                    "value"] + " " + property["unit"]
            if item.product.is_configurable_product():
                for property in item.get_properties():
                    item_name += "\n" + property["title"] + ": " + property[
                        "value"] + property["unit"] + " " + property["price"]
            price = currency(item.product_price_gross)
            if item.product.price_unit:
                price += " / " + item.product.price_unit
            total = currency(item.price_gross)
            order_items.append(
                [item.product.sku, item_name, amount, price, total])

        if self.order.voucher_number:
            order_items.append([
                "", "Voucher", "1",
                currency(self.order.voucher_price),
                currency(self.order.voucher_price)
            ])

        order_items.append([
            "", "Versandart (" + self.order.shipping_method.name + ")", "1",
            currency(self.order.shipping_price),
            currency(self.order.shipping_price)
        ])
        order_items.append([
            "", "Zahlungsweise (" + self.order.payment_method.name + ")", "1",
            currency(self.order.payment_price),
            currency(self.order.payment_price)
        ])

        order_items.append(["", "", "", "Summe", currency(self.order.price)])
        order_items.append(
            ["", "", "", "Inkl. MwSt",
             currency(self.order.tax)])

        order_items_table = Table(order_items, (80, 238, 60, 70, 70))
        order_items_table.setStyle(in_order_items_style)

        story.append(order_items_table)
        story.append(Spacer(1, 40))

        # END
        story.append(Paragraph(getattr(settings, "IN_END"), styleN))

        doc.build(story, onFirstPage=self.page, onLaterPages=self.page)
        pdf.seek(0)
        return pdf
    def __init__(self, report: InterestTransferListReport, year: int,
                 today: str):
        self.snippets = get_custom_texts()
        self.buffer = io.BytesIO()
        self.today = today
        story = []

        self._setup_styles()

        doc = SimpleDocTemplate(self.buffer, pagesize=A4)
        doc.leftMargin = 1.5 * cm
        doc.rightMargin = 1.5 * cm
        doc.topMargin = 1.0 * cm
        doc.bottomMargin = 1.5 * cm

        for data in report.per_contract_data:
            story.extend(self._header(data))

            story.append(Spacer(1, 1.0 * cm))
            story.append(
                Paragraph(
                    f"Kontostand Direktkreditvertrag Nr. {data.contract.number}",
                    self.styleH2))

            story.append(Spacer(1, 1.0 * cm))
            story.append(
                Paragraph(f"Guten Tag {data.contract.contact.name}, ",
                          self.styleN))

            story.append(Spacer(1, 0.3 * cm))
            story.append(
                Paragraph((
                    f"der Kontostand des Direktkreditvertrags Nr. {data.contract.number} beträgt heute, "
                    f" am {today} {euro(data.contract.balance)}. "),
                          self.styleN))
            story.append(
                Paragraph(
                    f"Die Zinsen für das Jahr {year} berechnen sich wie folgt:",
                    self.styleN))
            story.append(Spacer(1, 0.3 * cm))
            story.append(interest_year_table(data.interest_rows, narrow=True))
            story.append(Spacer(1, 0.3 * cm))
            story.append(
                Paragraph(f"<b>Zinsen {year}:</b> {euro(data.interest)}",
                          self.styleN))
            story.append(Spacer(1, 0.5 * cm))
            story.append(
                Paragraph((
                    "Wir werden die Zinsen in den nächsten Tagen auf das im Vertrag angegebene Konto "
                    "überweisen. Bitte beachten Sie, dass Sie sich selbst um die Abführung von "
                    "Kapitalertragssteuer und Solidaritätszuschlag kümmern sollten, da wir das nicht "
                    "übernehmen können. "), self.styleN))
            story.append(Spacer(1, 0.5 * cm))
            story.append(Paragraph("Vielen Dank!", self.styleN))
            story.append(Spacer(1, 1.5 * cm))
            story.append(Paragraph("Mit freundlichen Grüßen", self.styleN))
            story.append(Spacer(1, 1.0 * cm))
            story.append(Paragraph(self.snippets['your_name'], self.styleN))
            story.append(
                Paragraph(f"für die {self.snippets['gmbh_name']}",
                          self.styleN))
            story.append(Spacer(1, 0.3 * cm))

            story.append(PageBreak())

        doc.build(story,
                  onFirstPage=self._draw_footer,
                  onLaterPages=self._draw_footer)
        self.buffer.seek(0)
                        default='setup.json',
                        help='setup configuration file')
    args = parser.parse_args()

    setup(args.setup, STYLES)

    doc = SimpleDocTemplate(args.output, pagesize=A4)

    elements = []

    payload = load_payload('application.json')
    elements.append(Spacer(0, 1 * cm))
    make_heading(elements, [payload['title']])
    make_application_text(elements, payload)
    make_human_signature(elements, payload)

    doc.leftMargin = 29
    doc.rightMargin = 29

    def make_first_page_ld(canvas, doc): return make_first_page(canvas, doc,
                                                                args.qr_code,
                                                                payload)

    decl = doc.build(elements,
                     onFirstPage=make_first_page_ld,
                     onLaterPages=make_later_pages)

    if args.certificate and args.password:
        crypto_sign(args.certificate, args.password, args.output)
    print(payload['digest'])
Ejemplo n.º 14
0
    def create_report(self, info):
        # Converting to PDF
        # document theme
        if local:
            doc = SimpleDocTemplate('{}_TestReport.pdf'.format(info["serialNo"]))
        else:
            doc = SimpleDocTemplate('/home/test/reports/{}_TestReport.pdf'.format(info["serialNo"]))
        doc.topMargin = 20
        doc.bottomMargin = 25
        doc.leftMargin = 25
        doc.rightMargin = 25
        doc.allowSplitting = False

        header_path = self.project_path + "/" + "header.png"
        if os.path.exists(header_path):
            header = Image(header_path, 8 * inch, 1 * inch)
            header.hAlign = "CENTRE"
            self.elements.append(header)
            self.elements.append(Spacer(1, 20))
        else:
            logging.warning("Header not found")

        self.elements.append(self.draw_line(colors.lightgrey))
        self.elements.append(Spacer(1, 1))
        self.elements.append(self.draw_line(colors.lightgrey))
        self.elements.append(Spacer(1, 3))
        self.elements.append(Paragraph("Serial No: " + info["serialNo"], self.styles['Title']))
        self.elements.append(self.draw_line(colors.lightgrey))
        self.elements.append(Spacer(1, 1))
        self.elements.append(self.draw_line(colors.lightgrey))
        self.elements.append(Spacer(1, 20))

        # Create Tables for each test

        # Device Info Table
        if info["deviceInfo"]:
            self.heading_block("Device Info")
            dev_table = pd.DataFrame(info["deviceInfo"], index=[0])
            dev_table = dev_table.T
            dev_table.reset_index(inplace=True)
            dev_table.columns = ["Item", "Detail"]
            dev_table.set_index(["Item"], inplace=True)
            dev_table.replace("", "N/A", inplace=True)
            self.draw_table(dev_table)

        # Mac Table
        if info["macInfo"]:
            self.heading_block("MAC Info")
            self.draw_table(info["macInfo"], column=["interface", "macaddr"])

        # Operation Table
        if info["operationInfo"]:
            self.heading_block("Operation Details")
            opt_table = pd.DataFrame(info["operationInfo"], index=[0])
            opt_table = opt_table.T
            opt_table.reset_index(inplace=True)
            opt_table.columns = ["Operation", "Status"]
            opt_table.set_index(["Operation"], inplace=True)
            opt_table.replace("", "N/A", inplace=True)
            self.draw_table(opt_table)

        # Test Table
        if info["testInfo"]:
            self.heading_block("Test Details")
            test_table = pd.DataFrame(info["testInfo"], index=[0])
            test_table = test_table.T
            test_table.reset_index(inplace=True)
            test_table.columns = ["Test", "Status"]
            test_table.set_index(["Test"], inplace=True)
            test_table.replace("", "N/A", inplace=True)
            self.draw_table(test_table)

        # Hardware Test Table

        if info["hwtestInfo"]:
            self.heading_block("Hardware Test Details")
            self.draw_table(info["hwtestInfo"], column=["item", "result", "detail"])

        # Burn test details
        if info["burntestInfo"]:
            self.heading_block("Burn Test Details")
            self.draw_table(info["burntestInfo"], column=["item", "result", "detail"])

        # Last test details
        if info["lasttestInfo"]:
            self.heading_block("Last Test Details")
            self.draw_table(info["lasttestInfo"], column=["item", "result", "detail"])

        # LanBurn Throughput Table
        self.heading_block("LanBurn Throughput")
        speed_table = pd.DataFrame.from_dict(info["performancestatsInfo"])
        speed_table.columns = [x.title() for x in speed_table.columns]
        speed_table.set_index(["Nic"], inplace=True)
        self.draw_table(speed_table)

        # LanBurn Throughput Bar Chart
        self.elements.append(Spacer(1, 30))
        filename = "lanburn.png"
        self.throughput_bar_chart(speed_table, self.project_path, filename)
        im = Image(filename, 4 * inch, 2.5 * inch)
        self.elements.append(im)

        if self.render_pdf:
            # Build all the elements to create a PDF
            doc.build(self.elements)
Ejemplo n.º 15
0
    def exec_command(self, spreadsheet_data, args):
        if len(args) < 2:
            print("You must insert output file name")
            return

        print("Generating PDF...")

        # creating doc template and setting up output sheet style
        doc = SimpleDocTemplate(args[1], pagesize=letter)
        pdfmetrics.registerFont(TTFont('Standard', 'src/font.ttf'))
        pdfmetrics.registerFont(TTFont('Bold', 'src/font-bold.ttf'))
        doc.leftMargin = 40
        styles = getSampleStyleSheet()
        style_h1 = ParagraphStyle(name='Heading1',
                                  fontName='Bold',
                                  fontSize=14,
                                  leading=22,
                                  spaceAfter=2)
        style_h2 = ParagraphStyle(name='Heading2',
                                  fontName='Standard',
                                  fontSize=12,
                                  leading=22,
                                  spaceAfter=1)
        space = Spacer(1, 0.20 * inch)
        table_style = TableStyle([
            ('FONT', (0, 0), (-1, -1), 'Standard'),
            ('ALIGN', (0, 0), (-2, 0), 'CENTER'),
            ('ALIGN', (0, 0), (0, -5), 'LEFT'),
            ('INNERGRID', (0, 0), (-1, -1), 0.50, colors.black),
            ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
        ])

        # collect information about room occupancy
        elements = []

        # iterate over any room
        for room_key, room in spreadsheet_data.room_data.data.items():
            print("Sala:",
                  str(room.building_id) + ' - ' + str(room.name) + "\n")
            line = Drawing(520, 10)
            line.add(Line(0, 7, 520, 7))
            elements.append(Paragraph(
                "Sala: " + str(room.building_id) + ' - ' + str(room.name),
                style_h1))
            elements.append(line)

            # for any room check occupancy for any day
            for day in self.tools.days_of_week[0:5]:
                print(self.tools.days_of_week_label[day])
                elements.append(
                    Paragraph(self.tools.days_of_week_label[day], style_h2))

                data_id = id(
                    spreadsheet_data.full_time_first_semester_event_data)
                semester_data = spreadsheet_data.full_time_first_semester_event_data.data

                event_data = [self.table_header]

                # for any day check occupancy in any time block
                if data_id in room.referenced_by:
                    for time_block in self.tools.time_blocks:
                        result = self.get_room_event_by_day(day, time_block,
                                                            room, data_id,
                                                            semester_data)
                        if len(result) == 0:
                            result = [self.tools.time_blocks[time_block], '',
                                      '', '', '']
                        else:
                            for item in result:
                                event_data.append(item)

                if len(event_data) <= 1:
                    event_data = self.get_empty_tab()

                # add new table do sheet
                table = Table(event_data, hAlign='LEFT')
                table.setStyle(table_style)
                elements.append(table)
                elements.append(KeepTogether(Spacer(10, 20)))
            print("------------------------------------------")

        try:
            doc.build(elements)
            print("END, pdf is generated")
        except:
            print("Error while generating pdf, check correct of sheet")
Ejemplo n.º 16
0
  def doPrint(self, app, qrcode_value, raw_score):
    pdf_file_name = tempfile.mktemp (".pdf")
    styles = getSampleStyleSheet ()
    h1 = styles["h1"]
    h1.alignment=TA_CENTER
    h1.fontSize = 36
    h1.spaceBefore = 10
    h1.spaceAfter = 22
    normal = styles["Normal"]
    normal.alignment=TA_CENTER
    normal.fontSize = 16
    starStyle = ParagraphStyle(name='Star',
                                  fontName='FontAwesome',
                                  fontSize=20,
                                  alignment=TA_CENTER,
                                  spaceAfter = 18)

    doc = SimpleDocTemplate (pdf_file_name)
    doc.pagesize = (8*cm, 29*cm)
    doc.topMargin = 0
    doc.leftMargin = 0
    doc.rightMargin = 0

    wheel_threshold = app.config.get('wheel_threshold')
    number_questions = app.config.get('number_questions')
    percent = float(raw_score) / float(number_questions)
    canWheel = float(percent) >= float(wheel_threshold) / float(number_questions)

    parts = []
    imagename = "images/stylo.png"
    normal.spaceAfter = 18
    if canWheel:
      parts.append(Paragraph(app.config.get('wheel_txt'), normal))

      d = barcode.createBarcodeDrawing("QR", width=4*cm, height=4*cm, barBorder=0, value=qrcode_value)
      d.hAlign = "CENTER"
      d.vAlign = "TOP"    
      parts.append(d)
    else:
      parts.append(Paragraph(app.config.get('no_wheel_txt'), normal))
      parts.append(Image(imagename, 4*cm, 4*cm))

    raw_score = min(raw_score, len(app.config.scoreValueTable())-1)
    parts.append(Paragraph(str(app.config.scoreValueTable()[raw_score]), h1))
    empty_star = u"\uF006"
    full_star = u"\uF005"
    
    stars = u""
    if percent <= 0.3:
      stars += 3 * empty_star
    elif percent < 0.6:
      stars += full_star + 2 * empty_star
    elif percent < 1:
      stars += 2 * full_star + empty_star
    else:
      stars += 3 * full_star
      
    parts.append(Paragraph(stars, starStyle))
    
    parts.append(Paragraph(app.config.get('url'), normal))
    doc.build(parts)
    #call([app.config.get('acrobat'), "", pdf_file_name])
    call([app.config.get('foxit'), "/t", pdf_file_name, app.config.get('printer_name')])