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
Пример #2
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
Пример #3
0
    def add_image(self,
                  filename,
                  *,
                  width=plx.NoEscape(r'0.8\textwidth'),
                  page=None,
                  placement=plx.NoEscape(r'\centering')):
        """Add an image to the figure.

        Args
        ----
        filename: str
            Filename of the image.
        width: str
            The width of the image
        page: int
            The page number of the PDF file for the image
        placement: str
            Placement of the figure, `None` is also accepted.

        """

        if width is not None:
            if self.escape:
                width = plx.escape_latex(width)

            image_options = 'width=' + str(width)

        if page is not None:
            image_options = [image_options, f'page={page:d}']

        if placement is not None:
            self.append(placement)

        self.append(
            plx.StandAloneGraphic(image_options=image_options,
                                  filename=plx.utils.fix_filename(filename)))