import pathlib import fitz import zipfile from Reports import * # The following defines the overall report object mediabox = fitz.paper_rect("a4") # the only required parameter report = Report(mediabox, font_families={"sans-serif": "ubuntu", "serif": "ubuntu"}) # Predefined HTML to define the header for all pages HEADER = ( """

Report Example

""" ) header = Block(html=HEADER, report=report) FOOTER = """
Report Footer
""" footer = Block(html=FOOTER, report=report) footer.make_story() HTML = """
""" national_flags = zipfile.ZipFile("flags.zip") def fetch_rows(): table_data = pathlib.Path("items.csv").read_bytes().decode() data = [l.split(";") for l in table_data.splitlines()] return data items = Table( report=report, html=HTML, top_row="header", fetch_rows=fetch_rows, archive=national_flags, alternating_bg=("#ccc", "#ddd", "#eee"), ) report.sections = [ [items, Options(cols=1, format="letter", newpage=True)], ] # set sections list report.header = [header] report.footer = [footer] # This generates the report and saves it to the given path name. report.run("output.pdf")