Beispiel #1
0
    def addHeader(self):
        # Add document header
        header = tex.PageStyle("header",
                               header_thickness=1,
                               footer_thickness=1)
        # Create left header
        with header.create(tex.Head("L")):
            header.append(f"Account name: {self.name}")
            header.append(tex.LineBreak())
            header.append(f"IBAN: {self.number}")

        # Create right header
        with header.create(tex.Head("R")):
            header.append(self.bank)

        # Create left footer
        with header.create(tex.Foot("L")):
            header.append("Econicer - Financial Report")

        # Create right footer
        with header.create(tex.Foot("R")):
            header.append("Page ")
            header.append(tex.Command("thepage"))

        self.doc.preamble.append(header)
        self.doc.change_document_style("header")
def produce_header_footer():
    """
    Adds a generic header/footer to the report. Includes the date and CFIA logo in the header + legend in the footer.
    """
    header = pl.PageStyle("header", header_thickness=0.1)

    image_filename = get_image()
    with header.create(pl.Head("L")) as logo:
        logo.append(
            pl.StandAloneGraphic(image_options="width=110px",
                                 filename=image_filename))

    # Date
    with header.create(pl.Head("R")):
        header.append("Date Report Issued: " +
                      datetime.today().strftime('%Y-%m-%d'))

    # Footer
    with header.create(pl.Foot("C")):
        with header.create(pl.Tabular('lcr')) as table:
            table.add_row(
                '',
                bold(
                    'Data interpretation guidelines can be found in RDIMS document ID: 10401305'
                ), '')
            table.add_row(
                '', bold('This report was generated with OLC AutoROGA v1.2'),
                '')
    return header
Beispiel #3
0
    def _export_pdf(self, fname: str):
        geometry_options = {"margin": "1in"}
        doc = pylatex.Document(geometry_options=geometry_options)
        header = pylatex.PageStyle("header")

        with doc.create(pylatex.MiniPage(align="c")):
            doc.append(
                pylatex.HugeText(pylatex.utils.bold("Practice Sessions")))
            doc.append(pylatex.LineBreak())

        with header.create(pylatex.Foot("L")):
            header.append("@2019 Musicavis")

        with header.create(pylatex.Foot("R")):
            header.append(pylatex.simple_page_number())

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

        for practice in self.practices:
            with doc.create(
                    pylatex.Section(
                        f"{practice.instrument.name.title()} ({practice.date:%a, %B %m %Y})"
                    )):
                self._add_list_itemize_latex(doc, "Goals",
                                             practice.goals.all())

                with doc.create(pylatex.Subsection("Exercises")):
                    with doc.create(pylatex.Itemize()) as itemize:
                        for x in practice.exercises.all():
                            itemize.add_item(
                                f"{x.name} at {x.bpm_start}-{x.bpm_end}bpm for {x.minutes}m"
                            )

                self._add_list_itemize_latex(doc, "Improvements",
                                             practice.improvements.all())
                self._add_list_itemize_latex(doc, "Positives",
                                             practice.positives.all())

            with doc.create(pylatex.Subsection("Notes:")):
                if practice.notes:
                    for note in practice.notes.split("\r\n"):
                        doc.append(note) if note else doc.append(
                            pylatex.NewLine())

        doc.generate_pdf(fname.split(".pdf")[0], clean=True)
Beispiel #4
0
    def __init__(self, path):
        # Declare data bank as empty dict
        self.mBank = {}
        # Set geometry options
        geometry_options = \
            {
                "landscape": True,
                "heightrounded": True,
                "a4paper": True,
                "headheight": "10mm",
                "tmargin": "15mm",
                "bottom": "10mm",
                "right": "15mm",
                "left": "15mm"
            }

        # Create document
        self.mDoc = pyl.Document(geometry_options=geometry_options,
                                 default_filepath=path + "/report")
        # Declare packages
        # self.mDoc.packages.append(pyl.Package("lscape", options="pdftex"))
        self.mDoc.packages.append(pyl.Package("float"))
        self.mDoc.add_color("LightGray", "rgb", "0.83, 0.83, 0.83")
        self.mDoc.add_color("DarkGray", "rgb", "0.66, 0.66, 0.66")
        # Create header
        header = pyl.PageStyle("header")
        # Create left header
        with header.create(pyl.Head("L")) as leftHeader:
            with leftHeader.create(
                    pyl.MiniPage(width=pyl.NoEscape(r"0.7\textwidth"),
                                 pos="c")) as logoWrapper:
                logoWrapper.append(
                    pyl.StandAloneGraphic(image_options="width=120px",
                                          filename="../Images/logo.png"))

        # Create right header
        with header.create(pyl.Head("R")):
            header.append("Electronics Workshop")

        # Append header to document
        self.mDoc.preamble.append(header)
        self.mDoc.change_document_style("header")

        return