예제 #1
0
    def make_doc(self, foirequest):
        doc = Document(
            lmodern=True,
            geometry_options={
                "a4paper": True,
                "margin": "1in",
            },
        )
        # Change font
        doc.packages.append(Package('fontspec,xunicode,array'))
        doc.packages.append(Package('sectsty'))
        doc.preamble.append(NoEscape("\\usepackage{helvet}"))
        doc.preamble.append(NoEscape("\\sectionfont{\\fontsize{12}{15}\\selectfont}"))

        # Adjust description list
        doc.packages.append(Package('enumitem'))
        doc.preamble.append(NoEscape("\\setlist[description]{labelindent=0cm,style=multiline,leftmargin=1.5cm}"))

        # Hyphenation
        doc.append(NoEscape("\\lefthyphenmin=5"))
        doc.append(NoEscape("\\sloppy"))

        # doc.preamble.append(Command('title', foirequest.title))
        # doc.preamble.append(Command('author', foirequest.get_absolute_domain_short_url()))
        # doc.preamble.append(Command('date', NoEscape('\\today')))
        # doc.append(NoEscape('\\maketitle'))

        # Set up header and footer
        header = PageStyle("header")
        with header.create(Foot("L")):
            header.append(italic(settings.SITE_NAME))
        with header.create(Head("C")):
            header.append(foirequest.title)
        with header.create(Foot("R")):
            header.append(str(
                _('Request #{request_no}').format(request_no=foirequest.pk)))
        with header.create(Foot("C")):
            header.append(italic(NoEscape(r'Seite \thepage\ von \pageref{LastPage}')))
        doc.preamble.append(header)
        doc.change_document_style("header")

        for i, message in enumerate(foirequest.messages):
            last = i == len(foirequest.messages) - 1
            add_message_to_doc(doc, message)
            if not last:
                doc.append(NewPage())

        return doc
예제 #2
0
def generate_eva_report():
		"""
    Generate a report which contains the evacution time for every test
    """
		geometry_options = {
		"head": "40pt",
		"margin": "0.5in",
		"bottom": "0.6in",
		"includeheadfoot": True
		}
		doc = Document(geometry_options=geometry_options)

		## Define style of report
		reportStyle = PageStyle("reportStyle")

		with reportStyle.create(Head("R")) as left_header:
				with left_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
				                                  pos='c', align='l')) as title_wrapper:
					title_wrapper.append(LargeText(bold("RiMEA-Projekt")))
					title_wrapper.append(LineBreak())
					title_wrapper.append(MediumText(bold("Anlyse")))

		doc.preamble.append(reportStyle)

		## Apply Pagestyle
		doc.change_document_style("reportStyle")

		## Create table
		with doc.create(LongTabu("X[c] X[c]",
		                       row_height=1.5)) as report_table:
				report_table.add_row(["Test",
				                    "evacuation time(s)"],
				                   mapper=bold)
				report_table.add_hline()

		## Write the results of 3 tests in table
		for i in range(1,4):
			report_table.add_row(i, get_evac_time(i)[0])

		doc.append(NewPage())

		doc.generate_pdf("RiMEA-Projekt Evacution Analyse", clean_tex=False)
예제 #3
0
파일: header.py 프로젝트: JelteF/PyLaTeX
def generate_header():
    geometry_options = {"margin": "0.7in"}
    doc = Document(geometry_options=geometry_options)
    # Add document header
    header = PageStyle("header")
    # Create left header
    with header.create(Head("L")):
        header.append("Page date: ")
        header.append(LineBreak())
        header.append("R3")
    # Create center header
    with header.create(Head("C")):
        header.append("Company")
    # Create right header
    with header.create(Head("R")):
        header.append(simple_page_number())
    # Create left footer
    with header.create(Foot("L")):
        header.append("Left Footer")
    # Create center footer
    with header.create(Foot("C")):
        header.append("Center Footer")
    # Create right footer
    with header.create(Foot("R")):
        header.append("Right Footer")

    doc.preamble.append(header)
    doc.change_document_style("header")

    # Add Heading
    with doc.create(MiniPage(align='c')):
        doc.append(LargeText(bold("Title")))
        doc.append(LineBreak())
        doc.append(MediumText(bold("As at:")))

    doc.generate_pdf("header", clean_tex=False)
예제 #4
0
def generate_unique():
    geometry_options = {
        "head": "40pt",
        "margin": "0.5in",
        "bottom": "0.6in",
        "includeheadfoot": True
    }
    doc = Document(geometry_options=geometry_options)

    # Generating first page style
    first_page = PageStyle("firstpage")

    # Header image
    with first_page.create(Head("L")) as header_left:
        with header_left.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
                                         pos='c')) as logo_wrapper:
            logo_file = os.path.join(os.path.dirname(__file__),
                                     'sample-logo.png')
            logo_wrapper.append(StandAloneGraphic(image_options="width=120px",
                                filename=logo_file))

    # Add document title
    with first_page.create(Head("R")) as right_header:
        with right_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
                                 pos='c', align='r')) as title_wrapper:
            title_wrapper.append(LargeText(bold("Bank Account Statement")))
            title_wrapper.append(LineBreak())
            title_wrapper.append(MediumText(bold("Date")))

    # Add footer
    with first_page.create(Foot("C")) as footer:
        message = "Important message please read"
        with footer.create(Tabularx(
                           "X X X X",
                           arguments=NoEscape(r"\textwidth"))) as footer_table:

            footer_table.add_row(
                [MultiColumn(4, align='l', data=TextColor("blue", message))])
            footer_table.add_hline(color="blue")
            footer_table.add_empty_row()

            branch_address = MiniPage(
                width=NoEscape(r"0.25\textwidth"),
                pos='t')
            branch_address.append("960 - 22nd street east")
            branch_address.append("\n")
            branch_address.append("Saskatoon, SK")

            document_details = MiniPage(width=NoEscape(r"0.25\textwidth"),
                                        pos='t', align='r')
            document_details.append("1000")
            document_details.append(LineBreak())
            document_details.append(simple_page_number())

            footer_table.add_row([branch_address, branch_address,
                                  branch_address, document_details])

    doc.preamble.append(first_page)
    # End first page style

    # Add customer information
    with doc.create(Tabu("X[l] X[r]")) as first_page_table:
        customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='h')
        customer.append("Verna Volcano")
        customer.append("\n")
        customer.append("For some Person")
        customer.append("\n")
        customer.append("Address1")
        customer.append("\n")
        customer.append("Address2")
        customer.append("\n")
        customer.append("Address3")

        # Add branch information
        branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='t!',
                          align='r')
        branch.append("Branch no.")
        branch.append(LineBreak())
        branch.append(bold("1181..."))
        branch.append(LineBreak())
        branch.append(bold("TIB Cheque"))

        first_page_table.add_row([customer, branch])
        first_page_table.add_empty_row()

    doc.change_document_style("firstpage")
    doc.add_color(name="lightgray", model="gray", description="0.80")

    # Add statement table
    with doc.create(LongTabu("X[l] X[2l] X[r] X[r] X[r]",
                             row_height=1.5)) as data_table:
        data_table.add_row(["date",
                            "description",
                            "debits($)",
                            "credits($)",
                            "balance($)"],
                           mapper=bold,
                           color="lightgray")
        data_table.add_empty_row()
        data_table.add_hline()
        row = ["2016-JUN-01", "Test", "$100", "$1000", "-$900"]
        for i in range(30):
            if (i % 2) == 0:
                data_table.add_row(row, color="lightgray")
            else:
                data_table.add_row(row)

    doc.append(NewPage())

    # Add cheque images
    with doc.create(LongTabu("X[c] X[c]")) as cheque_table:
        cheque_file = os.path.join(os.path.dirname(__file__),
                                   'chequeexample.png')
        cheque = StandAloneGraphic(cheque_file, image_options="width=200px")
        for i in range(0, 20):
            cheque_table.add_row([cheque, cheque])

    doc.generate_pdf("complex_report", clean_tex=False)
예제 #5
0
def generate_unique():
    geometry_options = {
        "head": "40pt",
        "margin": "0.5in",
        "bottom": "0.6in",
        "includeheadfoot": True
    }
    doc = Document(geometry_options=geometry_options)

    # Generating first page style
    first_page = PageStyle("firstpage")
    # Header image
    with first_page.create(Head("C")) as header_center:
        with header_center.create(
                MiniPage(width=NoEscape(r"0.50\textwidth"),
                         pos='c')) as logo_wrapper:
            logo_file = os.path.join(os.path.dirname(__file__),
                                     'sample-logo.png')
            logo_wrapper.append(
                StandAloneGraphic(image_options="width=300px",
                                  filename=logo_file))

    # Add document title
    # Add footer
    with first_page.create(Foot("C")) as footer:
        message = "Important message please read"
        with footer.create(
                Tabularx(
                    "X X X X",
                    width_argument=NoEscape(r"\textwidth"))) as footer_table:
            branch_address = MiniPage(width=NoEscape(r"0.25\textwidth"),
                                      pos='t')

            document_details = MiniPage(width=NoEscape(r"0.25\textwidth"),
                                        pos='t',
                                        align='r')
            document_details.append(LineBreak())
            document_details.append(simple_page_number())

            footer_table.add_row([
                branch_address, branch_address, branch_address,
                document_details
            ])

    doc.preamble.append(first_page)
    # End first page style

    # Add customer information
    with doc.create(Tabu("X[l] X[r]")) as first_page_table:
        customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='h')

        # Add branch information
        branch = MiniPage(width=NoEscape(r"0.49\textwidth"),
                          pos='t!',
                          align='r')

        first_page_table.add_row([customer, branch])
        first_page_table.add_empty_row()

    doc.change_document_style("firstpage")
    doc.add_color(name="lightgray", model="gray", description="0.80")
    print("Enter the Region")
    R = input(str)

    with doc.create(MiniPage(align='c')):
        doc.append(LargeText(bold("\n\n\n\n\n\n" + R)))
        doc.append(LineBreak())
    print("Enter the adress of home ")
    A = input(str)
    image_filename = os.path.join(os.path.dirname(__file__), 'home.jpg')
    with doc.create(Section('Example : ' + A)):
        with doc.create(Figure(position='h!')) as home_pic:
            home_pic.add_image(image_filename, width='490px')
    with doc.create(Section('Property information :')):
        with doc.create(Itemize()) as itemize:
            print("enter property type")
            x = input(str)
            itemize.add_item(bold("Property type : " + x))
            print("How many bedrooms ?")
            y = input(int)
            itemize.add_item(bold("Bedroom : " + y))
            print("How many bathrooms?")
            z = input(float)
            itemize.add_item(bold("Bathroom : " + z))
            print('Enter the year of built please:')
            a = input(int)
            itemize.add_item(bold("Year built : " + a))
            print('Enter the finished sqft :')
            b = input(int)
            itemize.add_item(bold("Finished sqft : " + b))
            print("Enter the estimate price")
            p1 = input(float)
            print('enter the estimate rent')
            p2 = input(float)
            doc.append(LineBreak())
            table1 = Tabular('|c|c|')
            table1.add_hline()
            table1.add_row(('Estimate price', 'Estimate rent'))
            table1.add_hline()
            table1.add_row((p1 + '$', p2 + '$'))
            table1.add_hline()

        doc.append(table1)
    with doc.create(Section('Financing')):
        with doc.create(Itemize()) as itemize:
            print('Enter type of loan')
            lo = input(str)
            itemize.add_item(bold("Loan Type: " + lo))
            print("Enter loan amount")
            la = input(float)
            itemize.add_item(bold("Loan Amount: " + la))
            print("enter the interest rate with %")
            IR = input(float)
            itemize.add_item(bold("Interest Rate: " + IR + "%"))
            print("enter LTV")
            LTV = input(float)
            itemize.add_item(bold("Loan to Value (LTV): " + LTV + "%"))
            print("enter loan term")
            LT = input(int)
            itemize.add_item(bold("Loan Term: " + LT + "years"))
            print("enter loan payment monthly")
            LPM = input(int)
            print("enter loan payment yearly")
            LPY = input(int)
            itemize.add_item(
                bold("Loan Payment: " + LPM + "(monthly), " + LPY +
                     "(yearly)"))

    with doc.create(Section('Assumptions')):
        with doc.create(Itemize()) as itemize:
            print("enter vacancy rate")
            vr = input(float)
            itemize.add_item(bold('Vacancy Rate' + vr))
            print("property managment")
            pr = input(float)
            itemize.add_item(bold('Property Managment' + pr))
            print("yearly expense")
            yex = input(float)
            itemize.add_item(bold('Yearly Expense incr' + yex))
            print("yearly rent")
            yr = input(float)
            itemize.add_item(bold('Yearly Rent incr' + yr))
            print("yearly equity")
            ye = input(float)
            itemize.add_item(bold('Yearly Equity incr' + ye))
            print("land value")
            lv = input(float)
            itemize.add_item(bold('Land Value' + lv))

        section = Section('Financial projection and expences analysis')
        test1 = Subsection(bold('Financial Projection'))
        test2 = Subsection(bold('Expences'))

        table2 = Tabular('|c|c|c|c|c|c|c|c|c|c|')
        table2.add_hline()
        table2.add_row(("Type", "Year 1", "Year 2", "Year 3", "Year 4",
                        "Year 5", "Year 10", "Year 15", "Year 20", "Year 30"))
        table2.add_hline()
        table2.add_row(("Total Annuel Income", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Total Annuel Expenses", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(
            ("Total Annuel Operating Expenses", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Total Annual Cash Flow", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Property Value", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Cash on Cash ROI", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Loan Balance", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Cumulative Cash Flow", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()
        table2.add_row(("Equity", 6, 7, 8, 8, 8, 8, 8, 8, 8))
        table2.add_hline()

        table3 = Tabular('|c|c|c|')
        table3.add_hline()
        table3.add_row(("   ", "Monthly", "Annually"))
        table3.add_hline()
        table3.add_row(("Repair Cost", 6, 7))
        table3.add_hline()
        table3.add_row(("Vacancy", 6, 7))
        table3.add_hline()
        table3.add_row(("Insurance", 6, 7))
        table3.add_hline()
        table3.add_row(("Taxes", 6, 7))
        table3.add_hline()
        table3.add_row(("hoe", 6, 7))
        table3.add_hline()
        table3.add_row(("Capital Expenditures", 6, 7))
        table3.add_hline()
        table3.add_row(("Property Managment", 6, 7))
        table3.add_hline()
        table3.add_row(("Other Expences", 6, 7))
        table3.add_hline()
        table3.add_row((LargeText(bold("Total")), 6, 7))
        table3.add_hline()

        test1.append(table2)
        test2.append(table3)
        section.append(test1)
        section.append(test2)
        doc.append(section)
        doc.append(LineBreak)
        print('Cap Rate')
        cap = input()
        print('Cash on Cash Return')
        cac = input()
        print('Retur on investment')
        roi = input()

    doc.append(
        LargeText(
            bold('Cap Rate :' + cap + '\n\n' + "Cash on Cash Return" + cac +
                 "\n\n" + "Return on Investment" + roi)))
    doc.generate_pdf("complex_report", clean_tex=False)
예제 #6
0
def generate_report(main_title, name, title, email, payroll):

    # For saving the report in the Desktop folder
    dir_output=os.path.join(
        '~',
        'Desktop',
        'absconbest_payroll',
        'output'
    )
    dir_output=os.path.expanduser(dir_output)
    geometry_options = {
        "head": "40pt",
        "margin": "0.5in",
        "bottom": "0.6in",
        "includeheadfoot": True
    }
    doc = Document(geometry_options=geometry_options)

    # Generating
    # first page style
    first_page = PageStyle("firstpage")

    # Header image
    with first_page.create(Head("L")) as header_left:
        with header_left.create(
            MiniPage(width=NoEscape(r"0.49\textwidth"), pos='c')
        ) as logo_wrapper:
            logo_file = 'logo.png'
            logo_wrapper.append(
                StandAloneGraphic(
                    image_options="width=120px",
                    filename=logo_file
                )
            )

    # Add document title
    with first_page.create(Head("R")) as right_header:
        with right_header.create(MiniPage(
            width=NoEscape(r"0.49\textwidth"),
            pos='c',
            align='r')
        ) as title_wrapper:
            title_wrapper.append(LargeText(bold('Payroll Report')))
            title_wrapper.append(LineBreak())
            title_wrapper.append(MediumText(bold(main_title)))

    # Add footer
    with first_page.create(Foot("C")):
        first_page.append(simple_page_number())

    doc.preamble.append(first_page)

    #Add employee information
    with doc.create(Tabu("X[l] X[r]")) as first_page_table:
        employee = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='h')
        employee.append(name)
        employee.append("\n")
        employee.append(title)
        employee.append("\n")
        employee.append(email)

        #Dummy table
        branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='t!',
                          align='r')
        # branch.append(bold("1181..."))
        # branch.append(LineBreak())
        # branch.append(bold("TIB Cheque"))

        first_page_table.add_row([employee, branch])
        first_page_table.add_empty_row()

    doc.change_document_style("firstpage")
    doc.add_color(name="lightgray", model="gray", description="0.80")

    #Add payroll table
    with doc.create(LongTabu("X[l] X[c] X[c] X[c] X[r]",
                             row_height=1.5)) as data_table:
        data_table.add_row(['Work',
                            'Rate Per Hour ($)',
                            'Time in Minutes',
                            'Time in Hours',
                            'Wage ($)'],
                           mapper=bold,
                           color="lightgray")
        data_table.add_empty_row()
        data_table.add_hline()

        #Following Pandas' API
        payroll=payroll.reset_index()
        for i in range(len(payroll.index)):
            try:
                row = [payroll['Work'][i],
                       round(payroll['Rate Per Hour'][i],0),
                       round(payroll['TIM'][i],0),
                       round(payroll['TIH'][i],3),
                       round(payroll['Wage'][i],1)]
            except TypeError:
                row = [payroll['Work'][i],
                       'n/a',
                       round(payroll['TIM'][i],0),
                       round(payroll['TIH'][i],3),
                       round(payroll['Wage'][i],1)]
            if (i%2)==0:
                data_table.add_row(row, color="lightgray")
            else:
                data_table.add_row(row)
        # data_table.add_row([payroll['Work'][l_p],
        #                     round(payroll['TIM'][l_p],0),
        #                     round(payroll['TIH'][l_p],3),
        #                     '',
        #                     round(payroll['Wage'][l_p],1)]
        # )

    doc.append(NewPage())

    doc.generate_pdf(
        filepath=os.path.join(
dir_output,
            main_title.lower().replace(" ","_").replace(",",""),
        ),
        clean_tex=True,
        clean=True,
    )
예제 #7
0
파일: complex_report.py 프로젝트: bobojef/A
def generate_unique():
    geometry_options = {
        "head": "40pt",
        "margin": "0.5in",
        "bottom": "0.6in",
        "includeheadfoot": True
    }
    doc = Document(geometry_options=geometry_options)

    # Generating first page style
    first_page = PageStyle("firstpage")

    # Header image
    with first_page.create(Head("L")) as header_left:
        with header_left.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
                                         pos='c')) as logo_wrapper:
            logo_file = os.path.join(os.path.dirname(__file__),
                                     'sample-logo.png')
            logo_wrapper.append(StandAloneGraphic(image_options="width=120px",
                                filename=logo_file))

    # Add document title
    with first_page.create(Head("R")) as right_header:
        with right_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
                                 pos='c', align='r')) as title_wrapper:
            title_wrapper.append(LargeText(bold("Bank Account Statement")))
            title_wrapper.append(LineBreak())
            title_wrapper.append(MediumText(bold("Date")))

    # Add footer
    with first_page.create(Foot("C")) as footer:
        message = "Important message please read"
        with footer.create(Tabularx(
                "X X X X",
                width_argument=NoEscape(r"\textwidth"))) as footer_table:

            footer_table.add_row(
                [MultiColumn(4, align='l', data=TextColor("blue", message))])
            footer_table.add_hline(color="blue")
            footer_table.add_empty_row()

            branch_address = MiniPage(
                width=NoEscape(r"0.25\textwidth"),
                pos='t')
            branch_address.append("960 - 22nd street east")
            branch_address.append("\n")
            branch_address.append("Saskatoon, SK")

            document_details = MiniPage(width=NoEscape(r"0.25\textwidth"),
                                        pos='t', align='r')
            document_details.append("1000")
            document_details.append(LineBreak())
            document_details.append(simple_page_number())

            footer_table.add_row([branch_address, branch_address,
                                  branch_address, document_details])

    doc.preamble.append(first_page)
    # End first page style

    # Add customer information
    with doc.create(Tabu("X[l] X[r]")) as first_page_table:
        customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='h')
        customer.append("Verna Volcano")
        customer.append("\n")
        customer.append("For some Person")
        customer.append("\n")
        customer.append("Address1")
        customer.append("\n")
        customer.append("Address2")
        customer.append("\n")
        customer.append("Address3")

        # Add branch information
        branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='t!',
                          align='r')
        branch.append("Branch no.")
        branch.append(LineBreak())
        branch.append(bold("1181..."))
        branch.append(LineBreak())
        branch.append(bold("TIB Cheque"))

        first_page_table.add_row([customer, branch])
        first_page_table.add_empty_row()

    doc.change_document_style("firstpage")
    doc.add_color(name="lightgray", model="gray", description="0.80")

    # Add statement table
    with doc.create(LongTabu("X[l] X[2l] X[r] X[r] X[r]",
                             row_height=1.5)) as data_table:
        data_table.add_row(["date",
                            "description",
                            "debits($)",
                            "credits($)",
                            "balance($)"],
                           mapper=bold,
                           color="lightgray")
        data_table.add_empty_row()
        data_table.add_hline()
        row = ["2016-JUN-01", "Test", "$100", "$1000", "-$900"]
        for i in range(30):
            if (i % 2) == 0:
                data_table.add_row(row, color="lightgray")
            else:
                data_table.add_row(row)

    doc.append(NewPage())

    # Add cheque images
    with doc.create(LongTabu("X[c] X[c]")) as cheque_table:
        cheque_file = os.path.join(os.path.dirname(__file__),
                                   'chequeexample.png')
        cheque = StandAloneGraphic(cheque_file, image_options="width=200px")
        for i in range(0, 20):
            cheque_table.add_row([cheque, cheque])

    doc.generate_pdf("complex_report", clean_tex=False)
예제 #8
0
def generate_unique():
    geometry_options = {
        "head": "40pt",
        "margin": "0.5in",
        "bottom": "0.6in",
        "includeheadfoot": True
    }
    doc = Document(geometry_options=geometry_options,
                   document_options="a4paper")

    # Generating first page style
    first_page = PageStyle("firstpage")

    # Header image
    with first_page.create(Head("L")) as header_left:
        with header_left.create(
                MiniPage(width=NoEscape(r"0.49\textwidth"),
                         pos='c')) as logo_wrapper:
            logo_file = os.path.join(os.path.dirname(__file__), logo_name)
            logo_wrapper.append(
                StandAloneGraphic(image_options="width=50px",
                                  filename=logo_file))

    # Add document title
    with first_page.create(Head("R")) as right_header:
        with right_header.create(
                MiniPage(width=NoEscape(r"0.49\textwidth"), pos='c',
                         align='r')) as title_wrapper:
            title_wrapper.append(LargeText(bold("Sjain ventures ltd")))
            title_wrapper.append(LineBreak())
            title_wrapper.append(MediumText(bold("C-246, Vallabhnagar")))
            title_wrapper.append(LineBreak())
            # title_wrapper.append(TextColor("gray", MediumText(bold("Raipur, CG"))))
            title_wrapper.append(MediumText(bold("Raipur, CG")))

    # Add footer
    # with first_page.create(Foot("C")) as footer:
    #     message = "Important message please read"
    #     with footer.create(Tabularx(
    #             "X X X X",
    #             width_argument=NoEscape(r"\textwidth"))) as footer_table:

    #         footer_table.add_row(
    #             [MultiColumn(4, align='l', data=TextColor("blue", message))])
    #         footer_table.add_hline(color="blue")
    #         footer_table.add_empty_row()

    #         branch_address = MiniPage(
    #             width=NoEscape(r"0.25\textwidth"),
    #             pos='t')
    #         branch_address.append("960 - 22nd street east")
    #         branch_address.append("\n")
    #         branch_address.append("Saskatoon, SK")

    #         document_details = MiniPage(width=NoEscape(r"0.25\textwidth"),
    #                                     pos='t', align='r')
    #         document_details.append("1000")
    #         document_details.append(LineBreak())
    #         document_details.append(simple_page_number())

    #         footer_table.add_row([branch_address, branch_address,
    #                               branch_address, document_details])

    # Newly added
    with first_page.create(Foot("L")) as right_footer:
        with right_footer.create(
                MiniPage(width=NoEscape(r"0.49\textwidth"), pos='l',
                         align='l')) as contact_wrapper:
            contact_wrapper.append(MediumText(bold("Alok Kumar Sharma")))
            contact_wrapper.append(LineBreak())
            contact_wrapper.append(MediumText("*****@*****.**"))
            contact_wrapper.append(LineBreak())
            contact_wrapper.append(MediumText("+91 7877681234"))

    doc.preamble.append(first_page)
    # End first page style

    # Add customer information
    with doc.create(Tabu("X[r]")) as first_page_table:
        # customer = MiniPage(width=NoEscape(r"0.9\textwidth"), pos='h')
        # customer.append("Verna Volcano")
        # customer.append("\n")
        # customer.append("For some Person")
        # customer.append("\n")
        # customer.append("Address1")
        # customer.append("\n")
        # customer.append("Address2")
        # customer.append("\n")
        # customer.append("Address3")

        # Add branch information
        branch = MiniPage(width=NoEscape(r"0.49\textwidth"),
                          pos='t!',
                          align='r')
        branch.append("http://sjainventures.com")
        branch.append(LineBreak())
        branch.append("*****@*****.**")
        # branch.append(LineBreak())
        # branch.append("+91 7877681234")

        first_page_table.add_row([branch])  # [customer, branch]
        first_page_table.add_empty_row()

    doc.change_document_style("firstpage")
    doc.add_color(name="lightgray", model="gray", description="0.80")

    # Add statement table
    # with doc.create(LongTabu("X[l] X[2l] X[r] X[r] X[r]",
    #                          row_height=1.5)) as data_table:
    #     data_table.add_row(["date",
    #                         "description",
    #                         "debits($)",
    #                         "credits($)",
    #                         "balance($)"],
    #                        mapper=bold,
    #                        color="lightgray")
    #     data_table.add_empty_row()
    #     data_table.add_hline()
    #     row = ["2016-JUN-01", "Test", "$100", "$1000", "-$900"]
    #     for i in range(25):
    #         if (i % 2) == 0:
    #             data_table.add_row(row, color="lightgray")
    #         else:
    #             data_table.add_row(row)

    with doc.create(Paragraph("Dear Rishikesh,")) as para1:
        para1.append(lorem_ipsum.LOREM_IPSUM_TEXT2)

    # doc.append(NewPage())

    # Add cheque images
    # with doc.create(LongTabu("X[c] X[c]")) as cheque_table:
    #     cheque_file = os.path.join(os.path.dirname(__file__),
    #                                'facebook_logo.png')
    #     cheque = StandAloneGraphic(cheque_file, image_options="width=200px")
    #     for i in range(0, 20):
    #         cheque_table.add_row([cheque, cheque])

    doc.generate_pdf("complex_report", clean_tex=False)
예제 #9
0
    def save_latex(self, reportsummary, filename, rel_path, Disp_3d_image):
        companyname = str(reportsummary["ProfileSummary"]['CompanyName'])
        companylogo = str(reportsummary["ProfileSummary"]['CompanyLogo'])
        groupteamname = str(reportsummary["ProfileSummary"]['Group/TeamName'])
        designer = str(reportsummary["ProfileSummary"]['Designer'])
        projecttitle = str(reportsummary['ProjectTitle'])
        subtitle = str(reportsummary['Subtitle'])
        jobnumber = str(reportsummary['JobNumber'])
        client = str(reportsummary['Client'])

        header = PageStyle("header")
        # Create center header
        with header.create(Head("C")):
            with header.create(Tabularx('|l|p{6cm}|l|X|')) as table:
                table.add_hline()
                # MultiColumn(4)
                table.add_row(('Company Name', companyname, 'Project Title',
                               projecttitle),
                              color='OsdagGreen')
                table.add_hline()
                table.add_row(
                    ('Group/Team Name', groupteamname, 'Subtitle', subtitle),
                    color='OsdagGreen')
                table.add_hline()
                table.add_row(('Designer', designer, 'Job Number', jobnumber),
                              color='OsdagGreen')
                table.add_hline()
                table.add_row(
                    ('Date', time.strftime("%d /%m /%Y"), 'Client', client),
                    color='OsdagGreen')
                table.add_hline()
        # Create right footer
        with header.create(Foot("R")):
            header.append(NoEscape(r'Page \thepage'))

        geometry_options = {
            "top": "1.2in",
            "bottom": "1in",
            "left": "0.6in",
            "right": "0.6in",
            "headsep": "0.8in"
        }
        doc = Document(geometry_options=geometry_options, indent=False)
        doc.packages.append(Package('amsmath'))
        doc.packages.append(Package('graphicx'))
        doc.packages.append(Package('needspace'))
        doc.add_color('OsdagGreen', 'HTML', 'D5DF93')
        doc.preamble.append(header)
        doc.change_document_style("header")

        with doc.create(Section('Design Conclusion')):
            with doc.create(Tabularx('|X|X|', row_height=1.2)) as table:
                table.add_hline()
                table.add_row(('Section Designation', 'Remarks'),
                              color='OsdagGreen')
                table.add_hline()
                table.add_row(
                    (reportsummary['Define Section']['Section Designation'],
                     'Pass'))
                table.add_hline()

        with doc.create(Section('Section Details')):
            with doc.create(Tabularx('|X|X|', row_height=1.2)) as table:
                table.add_hline()
                table.add_row(
                    (bold('Section Type'),
                     reportsummary['Define Section']['Section Type']))
                table.add_hline()
                table.add_row(
                    (bold('Section Template'),
                     reportsummary['Define Section']['Section Template']))
                table.add_hline()

        with doc.create(Section('Section Parameters')):
            with doc.create(Tabularx('|X|X|', row_height=1.2)) as table:
                for parameter in reportsummary['Define Section'][
                        'Section Parameters']:
                    para = reportsummary['Define Section'][
                        'Section Parameters'][parameter]
                    table.add_hline()
                    table.add_row((bold(para[0]), para[1]))
                table.add_hline()

        labels = [
            'Area, a(cm²)',
            'Moment of Inertia',
            'I_zz(cm4)',
            'I_yy(cm4)',
            'Radius of Gyration',
            'r_zz(cm)',
            'r_yy(cm)',
            'Centriod',
            'c_z(cm)',
            'c_y(cm)',
            'Plastic Section modulus',
            'Z_pz(cm³)',
            'Z_py(cm³)',
            'Elastic Section modulus',
            'Z_zz(cm³)',
            'Z_yy(cm³)',
        ]
        values = list(reportsummary['Section Properties'].values())
        Properties = [
            (labels[0], values[0]),
            (labels[1], ""),
            (labels[2], values[1]),
            (labels[3], values[2]),
            (labels[4], ""),
            (labels[5], values[3]),
            (labels[6], values[4]),
            (labels[7], ""),
            (labels[8], values[5]),
            (labels[9], values[6]),
            (labels[10], ""),
            (labels[11], values[7]),
            (labels[12], values[8]),
            (labels[13], ""),
            (labels[14], values[9]),
            (labels[15], values[10]),
        ]

        with doc.create(Section('Section Properties')):
            with doc.create(Tabularx('|X|X|', row_height=1.2)) as table:
                for ppty in Properties:
                    table.add_hline()
                    table.add_row((bold(ppty[0]), ppty[1]))
                table.add_hline()
        doc.append(NewPage())

        if (not 'TRAVIS' in os.environ):
            with doc.create(Section('3D View')):
                with doc.create(Figure(position='h!')) as view_3D:
                    view_3dimg_path = rel_path + Disp_3d_image
                    # view_3D.add_image(filename=view_3dimg_path, width=NoEscape(r'\linewidth'))
                    view_3D.add_image(filename=view_3dimg_path)

                    view_3D.add_caption('3D View')
        try:
            doc.generate_pdf(filename, compiler='pdflatex', clean_tex=False)
        except:
            pass
예제 #10
0
def generate_pdf(stroka):
    pdf_path = get_dir(
        'odli_pdf'
    ) + '\\' + stroka.Surname + ' ' + stroka.Firstname + ' ' + stroka.Patronymic
    logo_image = r'miaclogo.png'

    pdf = Document(pdf_path)
    pdf.packages.add(Package('babel', options='russian'))
    pdf.packages.add(Package('pdfx', options=NoEscape('a-1b')))
    pdf.packages.add(Package('inputenc', options='utf8'))
    pdf.packages.add(Package('fontenc', options='T2A'))
    pdf.packages.add(Package('geometry', options='a5paper'))

    first_page = PageStyle("firstpage")
    with first_page.create(Head("L")) as header_left:
        with header_left.create(
                MiniPage(width=NoEscape(r"0.49\textwidth"),
                         pos='l')) as logo_wrapper:
            logo_wrapper.append(
                StandAloneGraphic(image_options="width=120px",
                                  filename=logo_image))
        with header_left.create(
                MiniPage(width=NoEscape(r"0.49\textwidth"),
                         pos='c')) as logo_wrapper:
            logo_wrapper.append(NoEscape("Сгенерированно в СПб ГБУЗ МИАЦ"))
            logo_wrapper.append(NewLine())
            logo_wrapper.append(
                NoEscape("В основе данные, предоставленные лабораториями"))
    pdf.preamble.append(first_page)

    pdf.change_document_style("firstpage")
    pdf.add_color(name="lightgray", model="gray", description="0.80")
    pdf.append(HorizontalSpace(size="500px"))
    with pdf.create(
            Section(NoEscape("Исследование на COVID-19"), numbering=False)):
        pdf.append(NoEscape("Наименование лаборатории: " + stroka.Name_Lab))
        pdf.append(NewLine())
        pdf.append(NoEscape("Дата исследования: " + stroka.Date_Test))
        pdf.append(NewLine())
        pdf.append(NoEscape("Ответственный за исследование: "))
        pdf.append(NewLine())
        pdf.append(
            NoEscape(stroka.lab_familia + ' ' + stroka.lab_name + ' ' +
                     stroka.lab_secondname))
    with pdf.create(Section(NoEscape("Пациент: "), numbering=False)):
        pdf.append(
            LargeText(
                NoEscape(stroka.Surname + ' ' + stroka.Firstname + ' ' +
                         stroka.Patronymic)))
        pdf.append(NewLine())
        pdf.append(NewLine())
        pdf.append(NoEscape("Дата рождения: " + stroka.Birthday))
        pdf.append(NewLine())
        pdf.append(NoEscape("Паспорт: " + stroka.Passport))
        pdf.append(NewLine())
        pdf.append(NoEscape("СНИЛС: " + stroka.Snils))
        pdf.append(NewLine())
        pdf.append(NoEscape("ОМС: " + stroka.Policy_OMS))
        pdf.append(NewLine())
        pdf.append(NoEscape("Контактный номер: " + stroka.Phone))
        pdf.append(NewLine())
    with pdf.create(Section(NoEscape("Результат: "), numbering=False)):
        pdf.append(
            NoEscape(
                "Качественное обнаружение короновируса SARS 2 в различных образцах: "
            ))
        pdf.append(NewLine())
        pdf.append(NewLine())
        if stroka.Result_Test == 'ND':
            pdf.append(TextColor('green',
                                 LargeText(NoEscape('Не обнаружено'))))
        if stroka.Result_Test == 'DET':
            pdf.append(TextColor('red', LargeText(NoEscape('Обнаружено'))))

    pdf.generate_pdf(clean_tex=True, compiler='pdflatex')

    with open(pdf_path + '.pdf', "rb") as pdf_file:
        encoded_pdf = base64.b64encode(pdf_file.read()).decode()
    return encoded_pdf
예제 #11
0
def gen_pdf(data):
    '''
    This function generates a pdf prayer time schedule using latexself.
    It takes a Tawqeetex object (data) that must be initialized before the call.
    '''
    geometry_options = {"tmargin": "3cm", "bmargin": "2cm", "rmargin": "2cm", "lmargin": "2cm"}
    doc = Document(geometry_options=geometry_options)

    # Add packages for arabic text
    doc.preamble.append(NoEscape(r'\usepackage[T2A,LAE,T1]{fontenc}'))
    doc.preamble.append(NoEscape(r'\usepackage[arabic, USenglish]{babel}'))

    # Add document header
    header = PageStyle("header") # header_thickness=0, footer_thickness=0
    # # Create left header
    # with header.create(Head("L")):
    #     header.append("")
    # # Create center header
    # with header.create(Head("C")):
    #     header.append("")
    # # Create right header
    # with header.create(Head("R")):
    #     header.append("logo goes here")
    # Create center footer
    with header.create(Foot("C")):      #NOTE: L and R footer are also available
        header.append("Generated with tawqeeTeX")

    # Add Heading
    doc.preamble.append(header)
    doc.change_document_style("header")

    doc.append(NoEscape(r'\begin{center}'))

    #doc.append(VerticalSpace('20pt'))
    doc.append(LargeText(bold(get_title_str(data.lang, data.month, data.year))))
    doc.append(VerticalSpace('20pt'))
    doc.append(LineBreak())
    doc.append(LargeText(italic(data.city)))
    doc.append(VerticalSpace('20pt'))
    doc.append(LineBreak())

    doc.append(NoEscape(r'\rowcolors{2}{green!10}{yellow!10}'))
    doc.append(NoEscape(r'\setlength{\arrayrulewidth}{0.5pt}'))

    # Create table for the prayer time schedule
    with doc.create(Tabular('|lc|cccccc|cr|', pos='c', row_height='1.35', col_space='7.5', width=10)) as table:

        table.add_hline()
        table.add_row(('', get_month_str(data.lang, data.month), 'Isha', 'Maghrib', 'Asr', 'Dhuhr',
                       'Shuruq', 'Fajr', NoEscape(r'\AR{' + data.months['hi'] + '}'),
                        ''), color='lightgray!20')
        table.add_row(('', '', *get_prayers_str(), '', ''), color='lightgray!20')
        table.add_hline()
        c = 0

        for day, weekday in data.date_gr.items():
            # Insert timings
            table.add_row(get_weekday_str(weekday, data.lang), day, data.isha[c], data.maghrib[c],
                          data.asr[c], data.dhuhr[c], data.sunrise[c], data.fajr[c], data.hi_day[c],
                          NoEscape(r'\AR{' + data.hi_weekday[c] + '}'))
            table.add_hline()
            c += 1

    doc.append(NoEscape(r'\end{center}'))
    doc.generate_pdf(data.city + '-' + data.month + '-' + data.year, clean_tex=False, silent=True)
예제 #12
0
def generate_unique(sectors_notirradiated, hv_notirradiated, spark_notirradiated, sectors_irradiated, hv_irradiated, spark_irradiated):
	geometry_options = {
		"head": "40pt",
		"margin": "0.5in",
		"bottom": "1.0in",
		"includeheadfoot": True
	}
	doc = Document(indent=False,geometry_options=geometry_options)

	# Generating first page style
	first_page = PageStyle("firstpage")

	# Header image
	with first_page.create(Head("L")) as header_left:
		with header_left.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
										 pos='c')) as logo_wrapper:
			logo_file = os.path.join(os.path.dirname(__file__),
									 '../cernlogo.png')
			logo_wrapper.append(StandAloneGraphic(image_options="width=80px",
								filename=logo_file))

	# Add document title
	with first_page.create(Head("R")) as right_header:
		with right_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
								 pos='c', align='r')) as title_wrapper:
			title_wrapper.append(LargeText(bold("ATLAS New Small Wheel")))
			title_wrapper.append(LineBreak())
			title_wrapper.append(bold("Integration Tests"))
			title_wrapper.append(LineBreak())
			title_wrapper.append(bold(now.strftime("%d-%m-%Y")))
			title_wrapper.append(LineBreak())
			title_wrapper.append("\n")
			title_wrapper.append(LargeText(bold("Chamber: "+str(chambername))))
			title_wrapper.append(LineBreak())
			title_wrapper.append("ID: "+str(ID))
			title_wrapper.append(LineBreak())

	# Add footer
	with first_page.create(Foot("C")) as footer:
		
		with footer.create(Tabularx(
				"X X X ",
				width_argument=NoEscape(r"\textwidth"))) as footer_table:

			footer_table.add_empty_row()

			footer_table.add_hline(color="blue")
			
			branch_address1 = MiniPage(
				width=NoEscape(r"0.25\textwidth"),
				pos='t')
			branch_address1.append("Lorenzo Pezzotti")
			branch_address1.append("\n")
			branch_address1.append("*****@*****.**")

			branch_address2 = MiniPage(
				width=NoEscape(r"0.25\textwidth"),
				pos='t')
			branch_address2.append("Alan Peyaud")
			branch_address2.append("\n")
			branch_address2.append("*****@*****.**")

			branch_address3 = MiniPage(
				width=NoEscape(r"0.25\textwidth"),
				pos='t')
			branch_address3.append("Ivan Gnesi")
			branch_address3.append("\n")
			branch_address3.append("*****@*****.**")

			document_details = MiniPage(width=NoEscape(r"0.2\textwidth"),
										pos='t', align='r')
			document_details.append(" ")
			document_details.append(LineBreak())
			document_details.append(simple_page_number())

			footer_table.add_row([branch_address1, branch_address2,
								  branch_address3])

	doc.append(first_page)
	# End first page style
	redcircle = glob.glob("redcircle.png")
	redcircle = StandAloneGraphic(redcircle, image_options="width=220px")

	# Add customer information
	with doc.create(Tabu("X[r]")) as first_page_table:
		'''
		# Add branch information
		branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='t!',
						  align='r')
		branch.append("Chamber name: ")
		branch.append(LineBreak())
		branch.append("ID: ")
		branch.append(LineBreak())
   
		first_page_table.add_row([branch])
		'''
		first_page_table.add_empty_row()

	doc.change_document_style("firstpage")
	doc.add_color(name="lightgray", model="gray", description="0.80")

	doc.append(NoEscape(r'\vspace{17.634mm}'))
	doc.append(LargeText(bold("Gas leak (mL/h) "))+str(gas_leak))
	
	with doc.create(Section('HV not irradiated', numbering=False)):
	   # Add statement table
		doc.append("\n")
		doc.append(timeslot)
		doc.append(LineBreak())
		doc.append(str(deltatime/60)+str("_min"))
		doc.append(LineBreak())
		doc.append("Spike_treshold_0.05_uA")
		doc.append(LineBreak())
		with doc.create(LongTabu("X[l] X[r] X[r] X[r]",
								 row_height=1.5)) as data_table:
			data_table.add_row(["Sector",
								"HV",
								"spark/min",
								"Flag"],
							   mapper=bold,
							   color="lightgray")
			data_table.add_empty_row()
			data_table.add_hline()
			row = ["sector", "hv", "spark", "0 or 1"]
			acceptedlist = []
			for i in range(len(hv_notirradiated)):
				if (i % 2) == 0:
					'''
					if int(hv_notirradiated[i]) > 567.9 and spark_notirradiated[i]<1.0:
						accepted = 1
						acceptedlist.append(accepted)

					else:
						accepted = 0
						acceptedlist.append(accepted) 
					'''
					if int(hv_notirradiated[i]) > 567.9:
						hvcolor = "black"

					if 548.0 < int(hv_notirradiated[i]) < 567.9:
						hvcolor = "orange"

					if int(hv_notirradiated[i])< 548.0:
						hvcolor = "red"

					if spark_notirradiated[i] > 1.0:
						sparkcolor = "red"

					if spark_notirradiated[i] < 1.0:
						sparkcolor = "black"

					if sparkcolor == "black" and hvcolor == "black":
						acceptedcolor = "black"

					if sparkcolor == "red" or hvcolor == "red":
						acceptedcolor = "red"

					if sparkcolor == "orange" and hvcolor == "orange":
						acceptedcolor = "orange" 

					if sparkcolor == "orange" and hvcolor == "black":
						acceptedcolor = "orange"

					if sparkcolor == "black" and hvcolor == "orange":
						acceptedcolor = "orange"

					if acceptedcolor == "black":
						accepted = 1
						acceptedlist.append(accepted)

					if acceptedcolor == "red":
						accepted = 0
						acceptedlist.append(accepted)

					if acceptedcolor == "orange":
						accepted = 2
						acceptedlist.append(accepted)

					data_table.add_row([str(sectors_notirradiated[i]), TextColor(hvcolor,str(int(hv_notirradiated[i]))), TextColor(sparkcolor, str(round(spark_notirradiated[i],2))), TextColor(acceptedcolor, "V")], color="lightgray")
				else:
					'''
					if int(hv_notirradiated[i]) > 567.9 and spark_notirradiated[i]<1.0:
						accepted = 1
						acceptedlist.append(accepted)
					else:
						accepted = 0
						acceptedlist.append(accepted)  
					'''

					if int(hv_notirradiated[i]) > 567.9:
						hvcolor = "black"

					if 548.0 < int(hv_notirradiated[i]) < 567.9:
						hvcolor = "orange"

					if int(hv_notirradiated[i])< 548.0:
						hvcolor = "red"

					if spark_notirradiated[i] > 1.0:
						sparkcolor = "red"

					if spark_notirradiated[i] < 1.0:
						sparkcolor = "black"

					if sparkcolor == "black" and hvcolor == "black":
						acceptedcolor = "black"

					if sparkcolor == "red" or hvcolor == "red":
						acceptedcolor = "red"

					if sparkcolor == "orange" and hvcolor == "orange":
						acceptedcolor = "orange" 

					if sparkcolor == "orange" and hvcolor == "black":
						acceptedcolor = "orange"

					if sparkcolor == "black" and hvcolor == "orange":
						acceptedcolor = "orange"

					if acceptedcolor == "black":
						accepted = 1
						acceptedlist.append(accepted)

					if acceptedcolor == "red":
						accepted = 0
						acceptedlist.append(accepted)

					if acceptedcolor == "orange":
						accepted = 2
						acceptedlist.append(accepted)

					data_table.add_row([str(sectors_notirradiated[i]), TextColor(hvcolor,str(int(hv_notirradiated[i]))), TextColor(sparkcolor, str(round(spark_notirradiated[i],2))), TextColor(acceptedcolor,"V")])

			data_table.add_empty_row()
			data_table.add_hline()
			data_table.add_row("Out of spec", str(len([x for x in hv_notirradiated if x < 560.0])), str(len([x for x in spark_notirradiated if x > 1.0])), str(acceptedlist.count(0)))
	
	with doc.create(Section('Summary not irradiated', numbering=False)):

		piecart.create_pie([acceptedlist.count(1), acceptedlist.count(0), acceptedlist.count(2)], "piechart.pdf")

	
		 # Add cheque images
		with doc.create(LongTabu("X[c]")) as summary1_table:
			pie = glob.iglob("piechart.pdf")
			#png_list = [StandAloneGraphic(x, image_options="width=120px") for x in png_list]
			pienew = [StandAloneGraphic(x, image_options="width=220px") for x in pie]
			summary1_table.add_row([pienew[0]])
		
		#here I have sectors_notirradiated, hv_notirradiated, spark_notirradiated, acceptedlist
		SM1channels = ["L1","R1","L2","R2","L3","R3","L4","R4","L5","R5"]
		SM2channels = ["L6","R6","L7","R7","L8","R8"]
		badresultsall = []
		badresultseta = []
		badresultsstereo = []

		if chambername[0:3] == "SM1":
		   channels = SM1channels
		if chambername[0:3] == "SM2":
		   channels = SM2channels
		if chambername[0:3] == "LM1":
			channels = SM1channels

		for channel in channels:
		   cntall = sum(1 for x, sector in enumerate(sectors_notirradiated) if sector[2:4] == channel and acceptedlist[x] == 1)
		   cnteta = sum(1 for x, sector in enumerate(sectors_notirradiated) if sector[2:4] == channel and (sector[1:2] == "1" or sector[1:2] == "2") and acceptedlist[x] == 1)
		   cntstereo = sum(1 for x, sector in enumerate(sectors_notirradiated) if sector[2:4] == channel and (sector[1:2] == "3" or sector[1:2] == "4") and acceptedlist[x] == 1) 
		   badresultsall.append(4-int(cntall))
		   badresultseta.append(2-int(cnteta))
		   badresultsstereo.append(2-int(cntstereo))

		#doc.append(NewPage())

		with doc.create(LongTabu("X[l] X[r] X[r] X[r]",
								 row_height=1.5)) as data_table2:
			data_table2.add_row(["Sector overimposed (from eta side)",
								"Eta",
								"Stereo",
								"Eta+Stereo"],
								mapper=bold,
								color="lightgray")
			data_table2.add_empty_row()
			data_table2.add_hline()
			row = ["Sector (all layers)", "Out of spec (Eta)", "Out of spec (Stereo)", "Out of spec (E+S)"]
			
			for i in range(len(channels)):
				if (i % 2) == 0:
					data_table2.add_row([str(channels[i]), str(int(badresultseta[i])), str(badresultsstereo[i]), badresultsall[i]], color="lightgray")
				else:
					data_table2.add_row([str(channels[i]), str(int(badresultseta[i])), str(badresultsstereo[i]), badresultsall[i]])

	doc.append(NewPage())
	

	with doc.create(Section('HV irradiated at GIF', numbering=False)):
	   # Add statement table
		doc.append("\n")
		doc.append(timeslot_irradiated)
		doc.append(LineBreak())
		doc.append(str(deltatime_irradiated/60)+str("_min"))
		doc.append(LineBreak())
		doc.append("Spike_treshold_0.40_uA")
		doc.append(LineBreak())
		with doc.create(LongTabu("X[l] X[r] X[r] X[r]",
								 row_height=1.5)) as data_table_irradiated:
			data_table_irradiated.add_row(["Sector",
								"HV",
								"spark/min",
								"Flag"],
							   mapper=bold,
							   color="lightgray")
			data_table_irradiated.add_empty_row()
			data_table_irradiated.add_hline()
			row = ["sector", "hv", "spark", "0 or 1"]
			acceptedlist = []
			for i in range(len(hv_irradiated)):
				if (i % 2) == 0:
					'''
					if int(hv_irradiated[i]) > 567.9 and spark_irradiated[i]<1.0:
						accepted = 1
						acceptedlist.append(accepted)
					else:
						accepted = 0
						acceptedlist.append(accepted) 
					'''
					if int(hv_irradiated[i]) > 567.9:
						hvcolor = "black"

					if 548.0 < int(hv_irradiated[i]) < 567.9:
						hvcolor = "orange"

					if int(hv_irradiated[i])< 548.0:
						hvcolor = "red"

					if spark_irradiated[i] > 1.0:
						sparkcolor = "red"

					if spark_irradiated[i] < 1.0:
						sparkcolor = "black"

					if sparkcolor == "black" and hvcolor == "black":
						acceptedcolor = "black"

					if sparkcolor == "red" or hvcolor == "red":
						acceptedcolor = "red"

					if sparkcolor == "orange" and hvcolor == "orange":
						acceptedcolor = "orange" 

					if sparkcolor == "orange" and hvcolor == "black":
						acceptedcolor = "orange"

					if sparkcolor == "black" and hvcolor == "orange":
						acceptedcolor = "orange"

					if acceptedcolor == "black":
						accepted = 1
						acceptedlist.append(accepted)

					if acceptedcolor == "red":
						accepted = 0
						acceptedlist.append(accepted)

					if acceptedcolor == "orange":
						accepted = 2
						acceptedlist.append(accepted)

					data_table_irradiated.add_row([str(sectors_irradiated[i]), TextColor(hvcolor,str(int(hv_irradiated[i]))), TextColor(sparkcolor, str(round(spark_irradiated[i],2))), TextColor(acceptedcolor,"V")], color="lightgray")
				else:
					'''
					if int(hv_irradiated[i]) > 567.9 and spark_irradiated[i]<1.0:
						accepted = 1
						acceptedlist.append(accepted)
					else:
						accepted = 0
						acceptedlist.append(accepted)  
					'''
					if int(hv_irradiated[i]) > 567.9:
						hvcolor = "black"

					if 548.0 < int(hv_irradiated[i]) < 567.9:
						hvcolor = "orange"

					if int(hv_irradiated[i])< 548.0:
						hvcolor = "red"

					if spark_irradiated[i] > 1.0:
						sparkcolor = "red"

					if spark_irradiated[i] < 1.0:
						sparkcolor = "black"

					if sparkcolor == "black" and hvcolor == "black":
						acceptedcolor = "black"

					if sparkcolor == "red" or hvcolor == "red":
						acceptedcolor = "red"

					if sparkcolor == "orange" and hvcolor == "orange":
						acceptedcolor = "orange" 

					if sparkcolor == "orange" and hvcolor == "black":
						acceptedcolor = "orange"

					if sparkcolor == "black" and hvcolor == "orange":
						acceptedcolor = "orange"

					if acceptedcolor == "black":
						accepted = 1
						acceptedlist.append(accepted)

					if acceptedcolor == "red":
						accepted = 0
						acceptedlist.append(accepted)

					if acceptedcolor == "orange":
						accepted = 2
						acceptedlist.append(accepted)


					data_table_irradiated.add_row([str(sectors_irradiated[i]), TextColor(hvcolor, str(int(hv_irradiated[i]))), TextColor(sparkcolor,str(round(spark_irradiated[i],2))), TextColor(acceptedcolor,"V")])

			data_table_irradiated.add_empty_row()
			data_table_irradiated.add_hline()
			data_table_irradiated.add_row("Out of spec", str(len([x for x in hv_irradiated if x < 560.0])), str(len([x for x in spark_irradiated if x > 1.0])), str(acceptedlist.count(0)))

	with doc.create(Section('Summary irradiated at GIF', numbering=False)):

		piecart.create_pie([acceptedlist.count(1), acceptedlist.count(0), acceptedlist.count(2)], "newpie.pdf")

		# Add cheque images
		with doc.create(LongTabu("X[c]")) as summary2_table:
			newpie = glob.iglob("newpie.pdf")
			#png_list = [StandAloneGraphic(x, image_options="width=120px") for x in png_list]
			pie2new = [StandAloneGraphic(x, image_options="width=220px") for x in newpie]
			summary2_table.add_row([pie2new[0]])

	#doc.append(NewPage())

		#here I have sectors_irradiated, hv_irradiated, spark_irradiated, acceptedlist
		SM1channels = ["L1","R1","L2","R2","L3","R3","L4","R4","L5","R5"]
		SM2channels = ["L6","R6","L7","R7","L8","R8"]
		badresultsall = []
		badresultseta = []
		badresultsstereo = []

		if chambername[0:3] == "SM1":
		   channels = SM1channels
		if chambername[0:3] == "SM2":
		   channels = SM2channels

		for channel in channels:
		   cntall = sum(1 for x, sector in enumerate(sectors_irradiated) if sector[2:4] == channel and acceptedlist[x] == 1)
		   cnteta = sum(1 for x, sector in enumerate(sectors_irradiated) if sector[2:4] == channel and (sector[1:2] == "1" or sector[1:2] == "2") and acceptedlist[x] == 1)
		   cntstereo = sum(1 for x, sector in enumerate(sectors_irradiated) if sector[2:4] == channel and (sector[1:2] == "3" or sector[1:2] == "4") and acceptedlist[x] == 1) 
		   badresultsall.append(4-int(cntall))
		   badresultseta.append(2-int(cnteta))
		   badresultsstereo.append(2-int(cntstereo))

		#doc.append(NewPage())

		with doc.create(LongTabu("X[l] X[r] X[r] X[r]",
									 row_height=1.5)) as data_table2:
			data_table2.add_row(["Sector overimposed (from eta side)",
								"Eta",
								"Stereo",
								"Eta+Stereo"],
								mapper=bold,
								color="lightgray")
			data_table2.add_empty_row()
			data_table2.add_hline()
			row = ["Sector (all layers)", "Out of spec (Eta)", "Out of spec (Stereo)", "Out of spec (E+S)"]
			
			for i in range(len(channels)):
				if (i % 2) == 0:
					data_table2.add_row([str(channels[i]), str(int(badresultseta[i])), str(badresultsstereo[i]), badresultsall[i]], color="lightgray")
				else:
					data_table2.add_row([str(channels[i]), str(int(badresultseta[i])), str(badresultsstereo[i]), badresultsall[i]])
	
	doc.append(NewPage())
	with doc.create(Section('Current with no irradiation', numbering=False)):
	
	# Add cheque images
		with doc.create(LongTabu("X[c] X[c] X[c] X[c]")) as cheque_table:
			png_list = glob.glob('BB5-i*.pdf')
			png_list.sort(key=os.path.getmtime)
			png_list = [StandAloneGraphic(x, image_options="width=120px") for x in png_list]
			print len(png_list)
			row_image = []    
			i = 0
			for image in png_list:
				row_image.append(image)
				i = i +1
				if i==4:
					cheque_table.add_row([row_image[0], row_image[1], row_image[2], row_image[3]])
					row_image = []
					i=0

	png_list = []
	doc.append(NewPage())	

	with doc.create(Section('Current under irradiation', numbering=False)):
	
	# Add cheque images
		with doc.create(LongTabu("X[c] X[c] X[c] X[c]")) as cheque_table:
			png_list = glob.glob('GIF-i*.pdf')
			png_list.sort(key=os.path.getmtime)
			png_list = [StandAloneGraphic(x, image_options="width=120px") for x in png_list]
			print len(png_list)
			row_image = []    
			i = 0
			for image in png_list:
				row_image.append(image)
				i = i +1
				if i==4:
					cheque_table.add_row([row_image[0], row_image[1], row_image[2], row_image[3]])
					row_image = []
					i=0

	png_list = []
	doc.append(NewPage())	

	with doc.create(Section('Current vs. flux (GIF)', numbering=False)):
	
	# Add cheque images
		with doc.create(LongTabu("X[c] X[c] X[c] X[c]")) as cheque_table:
			png_list = glob.glob('i*.pdf')
			png_list.sort(key=os.path.getmtime)
			png_list = [StandAloneGraphic(x, image_options="width=120px") for x in png_list]
			print len(png_list)
			row_image = []    
			i = 0
			for image in png_list:
				row_image.append(image)
				i = i +1
				if i==4:
					cheque_table.add_row([row_image[0], row_image[1], row_image[2], row_image[3]])
					row_image = []
					i=0
	
	doc.generate_pdf("complex_report", clean_tex=False, compiler='pdflatex')