Ejemplo n.º 1
0
def test_position():

    repr(HorizontalSpace(size='20pt', star=False))

    repr(VerticalSpace(size="20pt", star=True))

    # Test alignment environments
    center = Center()
    center.append("append")
    repr(center)

    right = FlushRight()
    right.append("append")
    repr(right)

    left = FlushLeft()
    left.append("append")
    repr(left)

    minipage = MiniPage(width=r"\textwidth",
                        height="10pt",
                        pos='t',
                        align='r',
                        content_pos='t',
                        fontsize="Large")
    minipage.append("append")
    repr(minipage)

    textblock = TextBlock(width="200",
                          horizontal_pos="200",
                          vertical_pos="200",
                          indent=True)
    textblock.append("append")
    textblock.dumps()
    repr(textblock)
Ejemplo n.º 2
0
    def create_document(self):
        geometry = {
            "head": "40pt",
            "margin": "1in",
            "bottom": "1in",
        }

        doc = Document(geometry_options=geometry)
        page = PageStyle("pagestyle")
        with page.create(Head("L")) as header_left:
            with header_left.create(
                    MiniPage(width=NoEscape(r"0.5\textwidth"),
                             pos="c")) as logo_wrapper:
                logo_file = os.path.join(get_current_directory(),
                                         "assets/" + LOGO).replace("\\", "/")
                logo_wrapper.append(
                    StandAloneGraphic(image_options="width=120px",
                                      filename=logo_file))

        with page.create(Head("R")) as right_header:
            with right_header.create(
                    MiniPage(width=NoEscape(r"0.5\textwidth"),
                             pos="c",
                             align="r")) as title_wrapper:
                title_wrapper.append(LargeText(bold("Vindskjerming")))

        doc.preamble.append(page)
        doc.change_document_style("pagestyle")
        return doc
Ejemplo n.º 3
0
def test_position():

    repr(HorizontalSpace(size='20pt', star=False))

    repr(VerticalSpace(size="20pt", star=True))

    # Test alignment environments
    center = Center()
    center.append("append")
    repr(center)

    right = FlushRight()
    right.append("append")
    repr(right)

    left = FlushLeft()
    left.append("append")
    repr(left)

    minipage = MiniPage(width=r"\textwidth", height="10pt", pos='t',
                        align='r', content_pos='t', fontsize="Large")
    minipage.append("append")
    repr(minipage)

    textblock = TextBlock(width="200", horizontal_pos="200",
                          vertical_pos="200", indent=True)
    textblock.append("append")
    textblock.dumps()
    repr(textblock)
Ejemplo n.º 4
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
Ejemplo n.º 5
0
    def create_head(self, param, value):

        with self.create(MiniPage(width=r"0.27\textwidth")):
            self.append(param)

        with self.create(MiniPage(width=r"0.68\textwidth")):
            self.append(bold(value))
Ejemplo n.º 6
0
    def fillFilehead(self):
        self.preamble.append(Command('usetikzlibrary','plotmarks'))
        self.preamble.append(Command('singlespacing'))
        self.preamble.append(Command('parindent 0ex'))

    # course configurations
        self.preamble.append(Command('newcommand',Arguments(Command('class'),NoEscape(self.__class__))))
        self.preamble.append(Command('newcommand',Arguments(Command('term'),NoEscape(self.__term__))))
        self.preamble.append(Command('newcommand',Arguments(Command('examnum'),NoEscape(self.__examnum__))))
        self.preamble.append(Command('newcommand',Arguments(Command('examdate'),NoEscape(self.__date__))))
        self.preamble.append(Command('newcommand',Arguments(Command('timelimit'),NoEscape(self.__timelimit__))))

    # document starts
    # some formation setting
        self.append(Command('pagestyle','head'))
        self.append(Command('firstpageheader',Arguments('', '', '')))

    # draw header, from head.head file
        self.append(Command('runningheader',Arguments(Command('class'),NoEscape(r'\examnum\ - Page \thepage\ of \numpages'))))
        self.append(Command('runningheadrule'))

        with self.create(LatexFulsh()) as fulsh:
            with fulsh.create(LatexTabular(arguments=NoEscape(r'p{2.8in} r l'))) as tabs:
                with open('edb_setting/header.cfg','r') as file:
                    header=file.read().split('<__|__>')
                    tabs.append(NoEscape(header[0]))
            fulsh.append(NoEscape(r'\\'))

        self.append(Command('rule',options='1ex',arguments=Arguments(Command('textwidth'),'.1pt')))
        self.append(Command('newcommand',Arguments(Command('boxwidth'),'0.8cm')))

    # draw statemnts, from coverpage.cfg, instructions for students
        with open('edb_setting/coverpage.cfg','r') as file:
            con=file.read()
            content=con.split('<__|__>')

        self.append(NoEscape(content[0]))
        with self.create(MiniPage(width='3.7in',pos='t')) as minipage:
            minipage.append(Command('vspace','0pt'))
            with minipage.create(Itemize()) as items:
                for itemcont in content[1:]:
                    items.add_item(NoEscape(itemcont))

            minipage.append(NoEscape(r'Do not write in the table to the right.'))

    # draw the score table
        self.append(Command('hfill'))
        with self.create(MiniPage(width='2.3in',pos='t')) as minipage:
            minipage.append(Command('vspace','0pt'))
            minipage.append(Command('gradetablestretch','2'))
            minipage.append(Command('vqword','Problem'))
            minipage.append(Command('addpoints'))
            # grade table setting
            gradetablesetting='v'
            # gradetablesetting='v][page'
            minipage.append(Command('gradetable',options=NoEscape(gradetablesetting)))

        self.append(Command('newpage'))
def column_with_margin(doc):
    with doc.create(
            MiniPage(width=r"0.33333\textwidth",
                     pos="t",
                     content_pos="t",
                     align="c")) as outer_page:
        with outer_page.create(
                MiniPage(width=r"0.9\textwidth",
                         pos="t",
                         content_pos="t",
                         align="l")) as page:
            yield page
Ejemplo n.º 8
0
    def _report_attack_configuration(self):
        """
        Create subsubsection about the attack and data configuration.
        """
        # Create tables for attack parameters and the data configuration.
        tm = 0  # Specify target model

        dc = self.data_conf
        self.report_section.append(Subsubsection("Attack Details"))
        with self.report_section.create(MiniPage()):
            with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
                self.report_section.append(Command("centering"))
                temp_pars_desc = self.pars_descriptors.copy()
                if "attack_model" in temp_pars_desc:
                    del temp_pars_desc["attack_model"]

                values = self.inference_attacks[tm].__dict__.copy()
                if hasattr(self, "hopskipjump_args"):
                    logger.debug("Include HopSkipJump params")
                    values.update(self.hopskipjump_args)
                report.create_attack_pars_table(
                    self.report_section,
                    values,
                    temp_pars_desc,
                )

            with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
                # -- Create table for the data configuration
                self.report_section.append(Command("centering"))
                nr_targets, attack_data_size = dc["attack_record_indices"].shape
                with self.report_section.create(Tabular("|l|c|")) as tab_dc:
                    tab_dc.add_hline()
                    tab_dc.add_row(["Attacked target models", nr_targets])
                    tab_dc.add_hline()
                    if "train_record_indices" in dc:
                        _, train_data_size = dc["train_record_indices"].shape
                        tab_dc.add_row(["Training set size", train_data_size])
                        tab_dc.add_hline()
                    if "test_record_indices" in dc:
                        _, test_data_size = dc["test_record_indices"].shape
                        tab_dc.add_row(["Test set size", test_data_size])
                        tab_dc.add_hline()
                    tab_dc.add_row(["Attack set size", attack_data_size])
                    tab_dc.add_hline()
                self.report_section.append(Command("captionsetup", "labelformat=empty"))
                self.report_section.append(
                    Command(
                        "captionof",
                        "table",
                        extra_arguments="Target and Data Configuration",
                    )
                )
    def _report_attack_results(self, save_path):
        """
        Create subsubsection describing the most important results of the attack.

        Parameters
        ----------
        save_path :
            Path to save the tex, pdf and asset files of the attack report.

        This subsection contains results only for the first target model.
        """
        tm = 0  # Specify target model
        self.report_section.append(Subsubsection("Attack Results"))
        res = self.attack_results

        # Histogram
        path = report.plot_class_dist_histogram(
            self.attack_alias, res["ec_accuracy_list"][tm], save_path
        )

        with self.report_section.create(MiniPage()):
            with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
                self.report_section.append(Command("centering"))
                self.report_section.append(
                    Command(
                        "includegraphics",
                        NoEscape(path),
                        "width=8cm",
                    )
                )
                self.report_section.append(Command("captionsetup", "labelformat=empty"))
                self.report_section.append(
                    Command(
                        "captionof",
                        "figure",
                        extra_arguments="Evaluation Accuracy Distribution",
                    )
                )

            with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
                self.report_section.append(Command("centering"))
                with self.report_section.create(Tabular("|l|c|")) as result_tab:
                    result_tab.add_hline()
                    result_tab.add_row(
                        ["Extracted model accuracy", round(res["ec_accuracy"][tm], 3)]
                    )
                    result_tab.add_hline()

                self.report_section.append(Command("captionsetup", "labelformat=empty"))
                self.report_section.append(
                    Command("captionof", "table", extra_arguments="Attack Summary")
                )
Ejemplo n.º 10
0
def generate_eva_report():

    geometry_options = {
        "head": "40pt",
        "margin": "0.5in",
        "bottom": "0.6in",
        "includeheadfoot": True
    }
    doc = Document(geometry_options=geometry_options)

    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)

    doc.change_document_style("reportStyle")

    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()

    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)
Ejemplo n.º 11
0
    def _report_attack_results(self):
        """
        Create subsubsection describing the most important results of the attack.

        This subsection contains results only for the first target model.
        """
        tm = 0  # Specify target model
        self.report_section.append(Subsubsection("Attack Results"))
        res = self.attack_results

        with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
            self.report_section.append(Command("centering"))
            with self.report_section.create(Tabular("|l|c|")) as result_tab:
                result_tab.add_hline()
                result_tab.add_row(["True Positives", round(res["tp"][tm], 3)])
                result_tab.add_hline()
                result_tab.add_row(["True Negatives", round(res["tn"][tm], 3)])
                result_tab.add_hline()
                result_tab.add_row(["False Positives", round(res["fp"][tm], 3)])
                result_tab.add_hline()
                result_tab.add_row(["False Negatives", round(res["fn"][tm], 3)])
                result_tab.add_hline()
                result_tab.add_row(["Accuracy", round(res["accuracy"][tm], 3)])
                result_tab.add_hline()
                result_tab.add_row(["Precision", round(res["precision"][tm], 3)])
                result_tab.add_hline()
                result_tab.add_row(["Recall", round(res["recall"][tm], 3)])
                result_tab.add_hline()

            self.report_section.append(Command("captionsetup", "labelformat=empty"))
            self.report_section.append(
                Command("captionof", "table", extra_arguments="Attack Summary")
            )
Ejemplo n.º 12
0
 def assinatura_tecnicos(self, profissionais):
     with self.create(Itemize()) as itemize:
         itemize.add_item(bold("Elaborado em,"))
         itemize.append(Command("vfill"))
         itemize.append(Command("centerline", "DataAtual: 11/12/2018"))
         itemize.append(Command("vfill"))
         itemize.add_item(bold("Visto, Revisado e Aprovado em, "))
         itemize.append(Command("vfill"))
         with itemize.create(MiniPage(align='c')):
             itemize.append("Data Ontem: 21/12/2018")
         itemize.append(Command("vfill"))
         with itemize.create(MiniPage(align='c')):
             carimbo = r"".join("-" * 40) + r"\\{}\\{}\\{}".format(
                 profissionais[0]['nome'], profissionais[0]['titulo'],
                 profissionais[0]['numConselho'])
             itemize.append(Command("textsc", NoEscape(carimbo)))
Ejemplo n.º 13
0
def print_workout(doc, lift, one_rm, no, accessorys):
    """Print one workout routine.

    Arguments:
        lift
        one_rm
        no
        accessorys

    Returns:
        One workout
    """
    doc.append(VerticalSpace("20pt"))
    doc.append(LineBreak())

    main_lift = gen_main_lift(lift, one_rm, no)
    access = gen_accessory_table(accessorys)

    with doc.create(MiniPage(width=r"0.5\textwidth")):
        doc.append(bold('Main Lift\n\n'))
        doc.append(main_lift)
        doc.append(VerticalSpace("20pt"))
        doc.append(LineBreak())
        doc.append(bold('Accessory Exercises\n\n'))
        doc.append(access)
        # doc.append(main_lift)

    doc.append(VerticalSpace("20pt"))
    doc.append(LineBreak())
    return doc
Ejemplo n.º 14
0
    def _add_overview(self, doc: Document, title: str = 'Overview') -> None:
        """Add overview section to document.

        :param doc:
        :param title:
        :return:
        """
        with doc.create(Section(title)):
            doc.append('Overview of kernel search results.')
            doc.append("\n")
            doc.append(VerticalSpace("10pt"))
            doc.append(LineBreak())

            best_kern_short = str(self.best_gp_model)
            best_kern_long = self.best_gp_model.covariance.infix_full

            with doc.create(MiniPage()):
                doc.append(bold("Best Kernel:"))
                doc.append("\n")
                doc.append(VerticalSpace("1pt"))
                doc.append(LineBreak())
                doc.append(italic("Short Form:"))
                doc.append("\n")
                doc.append(best_kern_short)
                doc.append("\n")
                doc.append(VerticalSpace("2.5pt"))
                doc.append(LineBreak())
                doc.append(italic("Long Form:"))
                doc.append("\n")
                doc.append(best_kern_long)
Ejemplo n.º 15
0
    def _report_attack_configuration(self):
        """
        Create subsubsection about the attack and data configuration.
        """
        # Create tables for attack parameters and the data configuration.
        tm = 0  # Specify target model

        dc = self.data_conf
        self.report_section.append(Subsubsection("Attack Details"))
        with self.report_section.create(MiniPage()):
            with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
                self.report_section.append(Command("centering"))
                temp_pars_desc = self.pars_descriptors.copy()
                if "verbose" in temp_pars_desc:
                    del temp_pars_desc["verbose"]
                values = self.inference_attacks[tm].__dict__.copy()

                report.create_attack_pars_table(
                    self.report_section,
                    values,
                    temp_pars_desc,
                )

            with self.report_section.create(MiniPage(width=r"0.49\textwidth")):
                # -- Create table for the data configuration
                self.report_section.append(Command("centering"))
                with self.report_section.create(Tabular("|l|c|")) as tab_dc:
                    tab_dc.add_hline()
                    tab_dc.add_row(["Attacked target models", len(self.target_models)])
                    tab_dc.add_hline()
                    if "initial_input_data" in dc:
                        input_size = dc["initial_input_data"][tm].shape[0]
                        tab_dc.add_row(["Input data size", input_size])
                        tab_dc.add_hline()
                    if "initial_input_targets" in dc:
                        target_size = len(dc["initial_input_targets"][tm])
                        tab_dc.add_row(["Target size", target_size])
                        tab_dc.add_hline()
                self.report_section.append(Command("captionsetup", "labelformat=empty"))
                self.report_section.append(
                    Command(
                        "captionof",
                        "table",
                        extra_arguments="Target and Data Configuration",
                    )
                )
Ejemplo n.º 16
0
def assinatura(doc, texto, largura, pos_env):
    doc.append(Command('bigskip'))
    doc.append(Command('bigskip'))
    doc.append(Command('bigskip'))
    with doc.create(pos_env) as pos:
        with pos.create(MiniPage(width=largura)) as mini:
            mini.append(Command('hrulefill'))
            mini.append(NewLine())
            mini.append(NoEscape(r'{}'.format(texto)))
Ejemplo n.º 17
0
    def gera_capa(self, json_ppra):
        self.preamble.append(
            Command('title',
                    'PPRA - Programa de Prevenção de Riscos Ambientais'))
        self.preamble.append(Command('author', json_ppra.get('nomeFilial')))
        self.preamble.append(Command('date', ''))

        logo_file = os.path.join(os.path.dirname(__file__), 'logo.png')

        with self.create(MiniPage(align='c')):
            self.append(
                StandAloneGraphic(image_options="width=5cm",
                                  filename=logo_file))
            self.append(NoEscape(r'\maketitle'))

        self.append(NoEscape(r'\vfill'))
        with self.create(MiniPage(align='c')):
            self.append("São Luís")
            self.append(LineBreak())
            self.append("Novembro/2018")
Ejemplo n.º 18
0
    def cria_subsecao(self, cabecalho, tri):

        notas = []
        for n in range(4):
            if self.notas[tri][n + 1] < 0:
                notas.append(0)
            else:
                notas.append(self.notas[tri][n + 1])

        colunas_subsection_1 = Tabular('c c')
        colunas_subsection_1.add_row([MultiColumn(2, align='c')])

        if tri == 0:
            graf_1tri = StandAloneGraphic(filename=self.path_graf_1tri,
                                          image_options='width = 190 px')
        elif tri == 1:
            graf_1tri = StandAloneGraphic(filename=self.path_graf_2tri,
                                          image_options='width = 190 px')
        elif tri == 2:
            graf_1tri = StandAloneGraphic(filename=self.path_graf_3tri,
                                          image_options='width = 190 px')

        box_1tri = MiniPage(width=NoEscape(r'0.49\textwidth'), pos='b')

        info_aluno_1tri = Tabular('c | c | c | c', pos='b')
        info_aluno_1tri.add_row(cabecalho, mapper=[bold])
        info_aluno_1tri.add_hline()
        info_aluno_1tri.add_empty_row()

        info_aluno_1tri.add_row([notas[0], notas[1], notas[2], notas[3]])

        box_1tri.append(info_aluno_1tri)
        box_1tri.append(NewLine())
        box_1tri.append(NewLine())
        box_1tri.append('*As notas das redações estão entre 0 e 8')
        for i in range(3):
            box_1tri.append(NewLine())

        colunas_subsection_1.add_row([graf_1tri, box_1tri])

        return colunas_subsection_1
Ejemplo n.º 19
0
def generate_cover2(doc):

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

    with doc.create(Figure(position='t')) as logo:
        logo.add_image("../../forms/jupedsim.png")

    doc.append(
        NoEscape(r"\textsc{\LARGE J\"ulich Pedestrian Simulator}\\[1.5cm]"))
    doc.append(
        NoEscape(r"\textsc{\small Forschungszentrum J\"ulich GmbH}\\[0.5cm]"))

    doc.append(NoEscape(r"\hrule \vspace{1.5mm}"))
    doc.append(
        NoEscape(r"{ \huge \bfseries RiMEA-Projekt Analyse Report}\\[0.4cm]"))
    doc.append(NoEscape(r"\hrule \vspace{5.5cm}"))

    author = get_git_status()[1] + "\par"
    date = get_git_status()[2] + "\par"
    branch = "Branch: " + get_git_status()[0] + "\par"
    commit = "Commit: " + get_git_status()[3] + "\par"

    InfoBlock = MiniPage(width=NoEscape(r"1\textwidth"), align='c')
    today = "Date: " + datetime.datetime.now().strftime(
        "%d - %m - %Y   (%H:%M)") + "\par"

    InfoBlock.append(NoEscape(today))
    InfoBlock.append(NoEscape(branch))
    InfoBlock.append(NoEscape(commit))

    doc.append(InfoBlock)

    doc.append(NoEscape(r"\end{center}"))
    doc.append(NoEscape(r"\end{titlepage}"))
Ejemplo n.º 20
0
def make_personal(doc, image=False):
    """Write up the personal data header
    """

    # doc.append(Command('hrule'))
    # doc.append(VerticalSpace("-5pt"))
    if image:
        with doc.create(MiniPage(width=r"0.45\textwidth")):
            # with doc.create(Figure()) as profil:
            doc.append(Command("centering"))
            doc.append(Command("includegraphics", PROFIL, "width=200pt"))

    with doc.create(MiniPage(width=r"0.6\textwidth")):
        with doc.create(Section(data['personal']['name'])):
            # doc.append(VerticalSpace("-3pt"))
            with doc.create(
                    Itemize(options=[
                        'align=parleft', 'leftmargin=2.25cm', 'labelwidth=2cm'
                    ])):
                # doc.append(Command("hrule"))
                doc.append(NoEscape("\\item[Phone]"))
                doc.append(phone_format(data['personal']['phone']))
                doc.append(NoEscape("\\item[Email]"))
                doc.append(Command("url", data['personal']['email'][0]))
                # doc.append(Command("url",data['personal']['email'][1]))
                doc.append(NoEscape("\\item[Website]"))
                doc.append(Command("url", data['personal']['website']))
                doc.append(NoEscape("\\item[Address]"))
                doc.append(NoEscape(",\\\\".join(data['personal']['address'])))
                doc.append(NoEscape("\\item[Birth]"))
                b = data['personal']['birth']
                birth = f"{b['day']} {b['month']['name']} {b['year']}"
                doc.append(NoEscape(birth + f", {b['city']}, {b['country']}"))

    # doc.append(Command('hrule'))
    doc.append(Command("hfill"))
Ejemplo n.º 21
0
def local_data_assinatura(doc):
    doc.append(Command('raggedleft'))
    doc.append(Command('bigskip'))
    with doc.create(MiniPage(width=r'.5\textwidth')):
        center = Center()
        center.append(Command('hrulefill'))
        center.append(NewLine())
        center.append(Command('bigskip'))
        center.append(Command('bigskip'))
        center.append(NoEscape(r'Local e data \\'))
        center.append(Command('hrulefill'))
        center.append(NewLine())
        center.append(Command('bigskip'))
        center.append(NoEscape('Assinatura do(a) Coordenador(a) da Atividade'))
        doc.append(center)
Ejemplo n.º 22
0
def generate_document_description(schema: PLDSchema, locale: LocaleDictionary,
                                  document: Document) -> Document:
    document.append(NewPage())
    total_man_days, man_days_distribution = generate_stats(schema)
    with document.create(MiniPage()) as minipage:
        minipage: MiniPage
        with minipage.create(
                Section(title=locale.document_description)) as section:
            section: Section
            with section.create(Tabularx(table_spec="|l|X|",
                                         row_height=1.4)) as tabularx:
                tabularx: Tabularx
                tabularx.add_row([
                    MultiColumn(1, data=locale.title, color="gray"),
                    schema.title
                ])
                tabularx.add_row([
                    MultiColumn(1, data=locale.description, color="gray"),
                    schema.description
                ])
                tabularx.add_row([
                    MultiColumn(1, data=locale.authors, color="gray"),
                    ", ".join(schema.authors)
                ])
                tabularx.add_row([
                    MultiColumn(1, data=locale.updated_date, color="gray"),
                    schema.versions[-1].date
                ])
                tabularx.add_row([
                    MultiColumn(1, data=locale.model_version, color="gray"),
                    schema.versions[-1].version
                ])
                tabularx.add_row(
                    [MultiColumn(2, color="gray", data=bold(locale.stats))])
                tabularx.add_row([
                    MultiColumn(1,
                                data=locale.man_days_distribution,
                                color="gray"),
                    NoEscape(f"{NewLine().dumps()} ".join([
                        f"{author}: {score:g}"
                        for author, score in man_days_distribution.items()
                    ]))
                ])
                tabularx.add_row([
                    MultiColumn(1, data=locale.total_man_days, color="gray"),
                    f"{total_man_days:g}"
                ])
    return document
Ejemplo n.º 23
0
    def build_answer(self, doc, q):

        if q._answer is not None:
            try:  # multiple choice
                # NOTE: need to access all_formatted_choices member of q._answer
                # so that try block will fail before an enumeration is created
                all_choices = self.MC_Answer_get_all_choices(q._answer)
                symb = r'\alph*)'
                try:
                    symb = ass.meta.config['answer']['multiple_choice/symbol']
                except:
                    pass
                doc.append(NoEscape(r' \\ '))
                with doc.create(MiniPage()):
                    with doc.create(
                            Enumerate(
                                enumeration_symbol=NoEscape(symb))) as clist:
                        for choice in all_choices:
                            label = r'\label{%s}' % choice[0]
                            clist.add_item(NoEscape(label + choice[1]))
            except:
                pass

            try:  # numerical
                ans = q._answer.quantity
                space = "2in"
                try:
                    space = ass.meta.config['answer']['numerical/spacing']
                except:
                    pass
                doc.append(NoEscape(r"\vspace{%s}" % space))
            except:
                pass

            try:  # text
                ans = q._answer.text
                space = "2in"
                try:
                    space = ass.meta.config['answer']['text/spacing']
                except:
                    pass
                doc.append(NoEscape(r"\vspace{%s}" % space))
            except:
                pass
Ejemplo n.º 24
0
def generate_deliverables(schema: PLDSchema, locale: LocaleDictionary,
                          document: Document) -> Document:
    with document.create(MiniPage()) as minipage:
        minipage: MiniPage
        with minipage.create(Section(title=locale.deliverable_map)) as section:
            section: Section

            for deliverable in schema.deliverables:
                with section.create(
                        Subsection(title=deliverable.name)) as subsection:
                    subsection: Subsection
                    subsets_length = len(deliverable.subsets)
                    tabular_length = subsets_length if subsets_length != 0 else 1
                    table_spec = f"|{'|'.join(['X'] * tabular_length)}|"
                    with subsection.create(
                            Tabularx(table_spec=table_spec,
                                     row_height="1.4")) as tabularx:
                        tabularx: Tabularx
                        tabularx.add_row([
                            MultiColumn(tabular_length,
                                        data=deliverable.name,
                                        color="gray")
                        ])

                        tabularx_contents: List[List[str]] = [[
                            f"{subset_index} {subset.name}"
                        ] + [
                            f"{subset_index}.{user_story_index} {user_story.name}"
                            for user_story_index, user_story in enumerate(
                                subset.user_stories, start=1)
                        ] for subset_index, subset in enumerate(
                            deliverable.subsets, start=1)]
                        max_size = max(
                            [len(content) for content in tabularx_contents])
                        tabularx_contents: List[List[str]] = [
                            content +
                            ["" for _ in range(len(content), max_size)]
                            for content in tabularx_contents
                        ]
                        for row_contents in zip(*tabularx_contents):
                            tabularx.add_row(
                                [row_content for row_content in row_contents])
    return document
Ejemplo n.º 25
0
def generate_cover2(doc):
		"""
		Generate a cover for generate_info_report func
		Without \maketitle in LaTeX, but using titlepage environment
		:param doc: LaTeX object, a instance of Document Class
		:return: null
		"""

		## Define titlepage in title environment
		doc.append(NoEscape(r"\begin{titlepage}"))
		doc.append(NoEscape(r"\begin{center}"))

		with doc.create(Figure(position='t', width=NoEscape(r'0.4\textwidth'))) as logo:
				logo.add_image("./figures/logo.png")

		doc.append(NoEscape(r"\textsc{\LARGE J\"ulich Pedestrian Simulator}\\[1.5cm]"))
		doc.append(NoEscape(r"\textsc{\small Forschungszentrum J\"ulich GmbH}\\[0.5cm]"))

		doc.append(NoEscape(r"\HRule \\[0.4cm]"))
		doc.append(NoEscape(r"{ \huge \bfseries RiMEA-Projekt Analyse Report}\\[0.4cm]"))
		doc.append(NoEscape(r"\HRule \\[1.5cm]"))

		## Add author date branch commit in a miniPage on title
		author = get_git_status()[1] + "\par"
		date = get_git_status()[2] + "\par"
		branch = "Branch: " + get_git_status()[0] + "\par"
		commit = "Commit: " + get_git_status()[3] + "\par"

		InfoBlock = MiniPage(width=NoEscape(r"0.8\textwidth"),
                align='c')
		InfoBlock.append(NoEscape(author))
		InfoBlock.append(NoEscape(date))
		InfoBlock.append(NoEscape(branch))
		InfoBlock.append(NoEscape(commit))

		doc.append(InfoBlock)

		doc.append(NoEscape(r"\end{center}"))
		doc.append(NoEscape(r"\end{titlepage}"))
Ejemplo n.º 26
0
def generate_labels():
    geometry_options = {"margin": "0.5in"}
    doc = Document(geometry_options=geometry_options)

    doc.change_document_style("empty")

    for i in range(10):
        with doc.create(MiniPage(width=r"0.5\textwidth")):
            doc.append("Vladimir Gorovikov")
            doc.append("\n")
            doc.append("Company Name")
            doc.append("\n")
            doc.append("Somewhere, City")
            doc.append("\n")
            doc.append("Country")

        if (i % 2) == 1:
            doc.append(VerticalSpace("20pt"))
            doc.append(LineBreak())

    doc.generate_pdf("minipage", clean_tex=False)
Ejemplo n.º 27
0
    def write_header(self, doc):
        # def write_header(self):

        # Add document header
        header = PageStyle("header")
        # Create left header
        with header.create(Head("L")):
            header.append(
                "Center for Reflected Text Analytics (CRETA)\nUniversity of Stuttgart"
            )
            # 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(NoEscape(r'\today'))
        ## Create left footer
        # with header.create(Foot("L")):
        #    header.append("Left Footer")
        ## Create center footer
        with header.create(Foot("C")):
            header.append(simple_page_number())
        ## 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("rCAT v0.1")))
            doc.append(LineBreak())
            doc.append(MediumText(bold("Relational Character Analysis Tool")))

        return doc
Ejemplo n.º 28
0
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("__")
        header.append(LineBreak())
        header.append("_")
    # Create center header
    with header.create(Head("C")):
        header.append("____")
    # 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='l')):
        doc.append(LargeText(bold("INVESTMENT PROPERTY - BUY & HOLD")))
        doc.append(LineBreak())
        doc.append(MediumText(bold(" ")))
    doc.generate_pdf("header", clean_tex=False)

    return print('nice')
Ejemplo n.º 29
0
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)
Ejemplo n.º 30
0
                    with doc.create(Section("Research Interests")):
                        doc.append(Command('hrule'))
                        with doc.create(Quote()):
                            doc.append(". ".join(data["research"]))
                    doc.append(Command("pagebreak"))
                # end subsection loop
                doc.append(VerticalSpace(NoEscape("-2pt")))
            # end subsections
        # end sections
        with doc.create(Section("Other Skills")):
            doc.append(Command('hrule'))

            for k, v in data['skills'].items():
                with doc.create(
                        MiniPage(width=NoEscape(r"0.33\textwidth"),
                                 pos='t',
                                 align='l')) as mp:
                    with mp.create(Subsection(k.title())):
                        # mp.append(VerticalSpace(NoEscape("-2pt")))
                        with mp.create(Itemize()):
                            for i in v:
                                mp.append(Command('item'))
                                if 'Latex' in i['item']:
                                    mp.append(Command("LaTeX"))
                                else:
                                    mp.append(bold(i['item']))
                                if i['description']:
                                    mp.append(": " + i['description'])
                                # mp.append(VerticalSpace(NoEscape("-2pt")))
                            mp.append(LineBreak())
Ejemplo n.º 31
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",
                    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)
Ejemplo n.º 32
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)