Пример #1
0
    def test_document(self, file):

        # create output directory if it does not exist yet
        if not self.output_dir.exists():
            self.output_dir.mkdir()

        # determine output location
        out_file = self.output_dir / (file.stem + "_out.pdf")

        # attempt to read PDF
        doc = None
        with open(file, "rb") as in_file_handle:
            print("\treading (1) ..")
            doc = PDF.loads(in_file_handle)

        # add annotation
        doc.get_page(0).append_polygon_annotation(
            points=LineArtFactory.sticky_note(
                Rectangle(Decimal(128), Decimal(128), Decimal(64),
                          Decimal(64))),
            stroke_color=X11Color("PowderBlue"),
        )

        # attempt to store PDF
        with open(out_file, "wb") as out_file_handle:
            print("\twriting ..")
            PDF.dumps(out_file_handle, doc)

        # attempt to re-open PDF
        with open(out_file, "rb") as in_file_handle:
            print("\treading (2) ..")
            doc = PDF.loads(in_file_handle)

        return True
Пример #2
0
    def test_add_polyline_annotation_using_lineart_factory(self):

        # create output directory if it does not exist yet
        if not self.output_file.parent.exists():
            self.output_file.parent.mkdir()

        # attempt to read PDF
        doc = None
        with open(self.input_file, "rb") as in_file_handle:
            print("\treading (1) ..")
            doc = PDF.loads(in_file_handle)

        # add annotation
        doc.get_page(0).append_polyline_annotation(
            points=LineArtFactory.droplet(
                Rectangle(Decimal(100), Decimal(100), Decimal(100),
                          Decimal(100))),
            stroke_color=X11Color("Crimson"),
        )

        # attempt to store PDF
        with open(self.output_file, "wb") as out_file_handle:
            print("\twriting ..")
            PDF.dumps(out_file_handle, doc)

        # attempt to re-open PDF
        with open(self.output_file, "rb") as in_file_handle:
            print("\treading (2) ..")
            doc = PDF.loads(in_file_handle)

        return True
    def test_write_document(self):

        # create output directory if it does not exist yet
        if not self.output_dir.exists():
            self.output_dir.mkdir()

        # create document
        pdf = Document()

        # add page
        page = Page()
        pdf.append_page(page)
        layout = SingleColumnLayout(page)

        # title
        layout.add(
            Paragraph(
                "Lissajours Line Art",
                font_size=Decimal(20),
                font_color=X11Color("Blue"),
            ))

        # table
        N = 7
        fill_colors = [
            HSVColor(Decimal(x / N), Decimal(1), Decimal(1))
            for x in range(0, N)
        ]
        stroke_colors = [HSVColor.darker(x) for x in fill_colors]
        fixed_bb = Rectangle(Decimal(0), Decimal(0), Decimal(100),
                             Decimal(100))
        t = Table(number_of_rows=N, number_of_columns=N)
        for i in range(0, N):
            for j in range(0, N):
                t.add(
                    Shape(
                        LineArtFactory.lissajours(fixed_bb, i + 1, j + 1),
                        fill_color=fill_colors[(i + j) % N],
                        stroke_color=stroke_colors[(i + j) % N],
                        line_width=Decimal(2),
                    ))

        t.set_padding_on_all_cells(Decimal(10), Decimal(10), Decimal(10),
                                   Decimal(10))
        layout.add(t)

        # determine output location
        out_file = self.output_dir / ("output.pdf")

        # attempt to store PDF
        with open(out_file, "wb") as in_file_handle:
            PDF.dumps(in_file_handle, pdf)

        # attempt to re-open PDF
        with open(out_file, "rb") as in_file_handle:
            PDF.loads(in_file_handle)
    def test_extract_text_with_regex(self):

        l = RegularExpressionTextExtraction("[dD]ue [dD]ate [0-9]+/[0-9]+/[0-9]+")
        file: Path = Path("/home/joris/Code/pdf-corpus/0600.pdf")
        with open(file, "rb") as pdf_file_handle:
            doc = PDF.loads(pdf_file_handle, [l])

        bounding_box: typing.Optional[Rectangle] = None
        output_file = self.output_dir / (file.stem + "_due_date_marked.pdf")
        with open(output_file, "wb") as pdf_file_handle:
            rects: typing.List[Rectangle] = [
                x.get_bounding_box()
                for x in l.get_matched_chunk_of_text_render_events_per_page(0)
            ]
            bounding_box = self.bounding_box(rects)
            doc.get_page(0).append_polygon_annotation(
                LineArtFactory.rectangle(bounding_box),
                stroke_color=X11Color("Red"),
            )
            PDF.dumps(pdf_file_handle, doc)

        # expand box a bit
        if bounding_box:
            p = Decimal(2)
            bounding_box = Rectangle(
                bounding_box.get_x() - p,
                bounding_box.get_y() - p,
                bounding_box.get_width() + 2 * p,
                bounding_box.get_height() + 2 * p,
            )

        l1 = SimpleTextExtraction()
        l2 = LocationFilter(
            bounding_box.get_x(),
            bounding_box.get_y(),
            bounding_box.get_x() + bounding_box.get_width(),
            bounding_box.get_y() + bounding_box.get_height(),
        ).add_listener(l1)

        with open(file, "rb") as pdf_file_handle:
            doc = PDF.loads(pdf_file_handle, [l2])

        print(l1.get_text(0))
 def _write_background(self, page: Page):
     layout = SingleColumnLayout(page)
     t = Table(number_of_columns=10, number_of_rows=25)
     for i in range(0, 25):
         for j in range(0, 10):
             put_star = random.choice([x <= 3 for x in range(0, 10)])
             if i < 11 and j >= 5:
                 t.add(Paragraph(" ", respect_spaces_in_text=True))
                 continue
             if put_star:
                 c = random.choice(
                     [
                         self.ACCENT_COLOR_1,
                         self.ACCENT_COLOR_2,
                         self.ACCENT_COLOR_3,
                         self.ACCENT_COLOR_4,
                         self.ACCENT_COLOR_5,
                     ]
                 )
                 t.add(
                     Shape(
                         LineArtFactory.n_pointed_star(
                             bounding_box=Rectangle(
                                 Decimal(0), Decimal(0), Decimal(16), Decimal(16)
                             ),
                             n=random.choice([3, 5, 7, 12]),
                         ),
                         fill_color=c,
                         stroke_color=c,
                         line_width=Decimal(1),
                     )
                 )
             else:
                 t.add(Paragraph(" ", respect_spaces_in_text=True))
     t.no_borders()
     t.set_padding_on_all_cells(Decimal(5), Decimal(5), Decimal(5), Decimal(5))
     layout.add(t)
    def test_extract_text_in_area(self):
        r = Rectangle(Decimal(50), Decimal(400), Decimal(200), Decimal(100))
        doc = None
        file: Path = Path("/home/joris/Code/pdf-corpus/0600.pdf")
        with open(file, "rb") as pdf_file_handle:
            doc = PDF.loads(pdf_file_handle)

        output_file = self.output_dir / (file.stem + "_bill_to_marked.pdf")
        with open(output_file, "wb") as pdf_file_handle:
            doc.get_page(0).append_polygon_annotation(
                LineArtFactory.rectangle(r),
                stroke_color=X11Color("Red"),
            )
            PDF.dumps(pdf_file_handle, doc)

        l1 = SimpleTextExtraction()
        l2 = LocationFilter(
            r.get_x(), r.get_y(), r.get_x() + r.get_width(), r.get_y() + r.get_height()
        ).add_listener(l1)

        with open(file, "rb") as pdf_file_handle:
            doc = PDF.loads(pdf_file_handle, [l2])

        print(l1.get_text(0))
    def test_write_document(self):

        # create output directory if it does not exist yet
        if not self.output_dir.exists():
            self.output_dir.mkdir()

        # create document
        pdf = Document()

        # add page
        page = Page()
        pdf.append_page(page)

        layout = SingleColumnLayout(page)
        t = Table(number_of_columns=10, number_of_rows=25)
        for _ in range(0, 10):
            for _ in range(0, 25):
                put_star = random.choice([x <= 3 for x in range(0, 10)])
                if put_star:
                    c: Color = random.choice(self.COLORS)
                    s: Decimal = random.choice(
                        [
                            Decimal(16),
                            Decimal(16),
                            Decimal(16),
                            Decimal(16),
                            Decimal(8),
                            Decimal(4),
                        ]
                    )
                    t.add(
                        Shape(
                            LineArtFactory.n_pointed_star(
                                bounding_box=Rectangle(Decimal(0), Decimal(0), s, s),
                                n=random.choice([3, 5, 7, 12]),
                            ),
                            fill_color=c,
                            stroke_color=c,
                            line_width=Decimal(1),
                        )
                    )
                else:
                    t.add(Paragraph(" ", respect_spaces_in_text=True))
        t.no_borders()
        t.set_padding_on_all_cells(Decimal(5), Decimal(5), Decimal(5), Decimal(5))
        layout.add(t)

        # footer
        rectangle_box = Rectangle(
            Decimal(0),
            Decimal(0),
            page.get_page_info().get_width(),
            page.get_page_info().get_height() * Decimal(0.1),
        )
        Shape(
            LineArtFactory.rectangle(rectangle_box),
            fill_color=self.COLORS[0],
            stroke_color=self.COLORS[0],
            line_width=Decimal(1),
        ).layout(page, rectangle_box)

        rectangle_box = Rectangle(
            Decimal(0),
            page.get_page_info().get_height() * Decimal(0.1),
            page.get_page_info().get_width(),
            Decimal(2),
        )
        Shape(
            LineArtFactory.rectangle(rectangle_box),
            fill_color=self.COLORS[1],
            stroke_color=self.COLORS[1],
            line_width=Decimal(1),
        ).layout(page, rectangle_box)

        # determine output location
        out_file = self.output_dir / "output.pdf"

        # attempt to store PDF
        with open(out_file, "wb") as in_file_handle:
            PDF.dumps(in_file_handle, pdf)

        with open(out_file, "rb") as in_file_handle:
            PDF.loads(in_file_handle)
    def test_write_document(self):

        # create output directory if it does not exist yet
        if not self.output_dir.exists():
            self.output_dir.mkdir()

        # create document
        pdf = Document()

        # add page
        page = Page()
        pdf.append_page(page)

        layout = MultiColumnLayout(page)

        # background
        self._write_background(page)

        # table
        avatar_urls = [
            "https://avatars.githubusercontent.com/u/" + str(x)
            for x in self.FIRST_100_STARS
        ]
        t = Table(number_of_columns=4, number_of_rows=25)
        for s in avatar_urls[0 : (4 * 25)]:
            im = PILImage.open(requests.get(s, stream=True).raw)
            t.add(Image(im, width=Decimal(20), height=Decimal(20)))
        t.set_padding_on_all_cells(Decimal(2), Decimal(2), Decimal(2), Decimal(2))
        t.no_borders()
        layout.add(t)

        layout.add(
            Paragraph(
                "100 stars!",
                font="Helvetica-Bold",
                font_size=Decimal(20),
                font_color=self.ACCENT_COLOR_1,
                horizontal_alignment=Alignment.CENTERED,
            )
        )

        # next column
        layout.switch_to_next_column()

        # paragraph
        layout.add(
            Paragraph(
                "Thank you,",
                font="Helvetica-Bold",
                font_size=Decimal(20),
                font_color=self.ACCENT_COLOR_1,
            )
        )
        layout.add(
            Paragraph(
                "Your support and encouragement have always been the driving factors in the development of pText. "
                "I want you to know that I value your appreciation immensely!"
            )
        )
        layout.add(
            Paragraph(
                "-- Joris Schellekens",
                font="Helvetica-Oblique",
                font_size=Decimal(8),
                font_color=self.ACCENT_COLOR_2,
            )
        )

        layout.add(
            Barcode(
                data="https://github.com/jorisschellekens/ptext-release/stargazers",
                type=BarcodeType.QR,
                width=Decimal(128),
                stroke_color=self.ACCENT_COLOR_1,
            )
        )

        # footer
        rectangle_box = Rectangle(
            Decimal(0),
            Decimal(0),
            page.get_page_info().get_width(),
            page.get_page_info().get_height() * Decimal(0.1),
        )
        Shape(
            LineArtFactory.rectangle(rectangle_box),
            fill_color=self.ACCENT_COLOR_1,
            stroke_color=self.ACCENT_COLOR_1,
            line_width=Decimal(1),
        ).layout(page, rectangle_box)

        rectangle_box = Rectangle(
            Decimal(0),
            page.get_page_info().get_height() * Decimal(0.1),
            page.get_page_info().get_width(),
            Decimal(2),
        )
        Shape(
            LineArtFactory.rectangle(rectangle_box),
            fill_color=self.ACCENT_COLOR_2,
            stroke_color=self.ACCENT_COLOR_2,
            line_width=Decimal(1),
        ).layout(page, rectangle_box)

        # determine output location
        out_file = self.output_dir / "output.pdf"

        # attempt to store PDF
        with open(out_file, "wb") as in_file_handle:
            PDF.dumps(in_file_handle, pdf)

        with open(out_file, "rb") as in_file_handle:
            PDF.loads(in_file_handle)
    def test_document(self, file):

        # create output directory if it does not exist yet
        if not self.output_dir.exists():
            self.output_dir.mkdir()

        # determine output location
        out_file = self.output_dir / (file.stem + "_out.pdf")

        # attempt to read PDF
        doc = None
        with open(file, "rb") as in_file_handle:
            print("\treading (1) ..")
            doc = PDF.loads(in_file_handle)

        shapes = [
            LineArtFactory.right_sided_triangle(
                Rectangle(Decimal(0), Decimal(0), Decimal(100), Decimal(100))),
            LineArtFactory.isosceles_triangle(
                Rectangle(Decimal(110), Decimal(0), Decimal(100),
                          Decimal(100))),
            LineArtFactory.parallelogram(
                Rectangle(Decimal(220), Decimal(0), Decimal(100),
                          Decimal(100))),
            LineArtFactory.trapezoid(
                Rectangle(Decimal(330), Decimal(0), Decimal(100),
                          Decimal(100))),
            LineArtFactory.diamond(
                Rectangle(Decimal(440), Decimal(0), Decimal(100),
                          Decimal(100))),
            # second row
            LineArtFactory.pentagon(
                Rectangle(Decimal(0), Decimal(110), Decimal(100),
                          Decimal(100))),
            LineArtFactory.hexagon(
                Rectangle(Decimal(110), Decimal(110), Decimal(100),
                          Decimal(100))),
            LineArtFactory.heptagon(
                Rectangle(Decimal(220), Decimal(110), Decimal(100),
                          Decimal(100))),
            LineArtFactory.octagon(
                Rectangle(Decimal(330), Decimal(110), Decimal(100),
                          Decimal(100))),
            LineArtFactory.regular_n_gon(
                Rectangle(Decimal(440), Decimal(110), Decimal(100),
                          Decimal(100)), 17),
            # third row
            LineArtFactory.fraction_of_circle(
                Rectangle(Decimal(0), Decimal(220), Decimal(100),
                          Decimal(100)),
                Decimal(0.25),
            ),
            LineArtFactory.fraction_of_circle(
                Rectangle(Decimal(110), Decimal(220), Decimal(100),
                          Decimal(100)),
                Decimal(0.33),
            ),
            LineArtFactory.fraction_of_circle(
                Rectangle(Decimal(220), Decimal(220), Decimal(100),
                          Decimal(100)),
                Decimal(0.5),
            ),
            LineArtFactory.fraction_of_circle(
                Rectangle(Decimal(330), Decimal(220), Decimal(100),
                          Decimal(100)),
                Decimal(0.75),
            ),
            LineArtFactory.droplet(
                Rectangle(Decimal(440), Decimal(220), Decimal(100),
                          Decimal(100))),
            # fourth row
            LineArtFactory.four_pointed_star(
                Rectangle(Decimal(0), Decimal(330), Decimal(100),
                          Decimal(100))),
            LineArtFactory.five_pointed_star(
                Rectangle(Decimal(110), Decimal(330), Decimal(100),
                          Decimal(100))),
            LineArtFactory.six_pointed_star(
                Rectangle(Decimal(220), Decimal(330), Decimal(100),
                          Decimal(100))),
            LineArtFactory.n_pointed_star(
                Rectangle(Decimal(330), Decimal(330), Decimal(100),
                          Decimal(100)), 8),
            LineArtFactory.n_pointed_star(
                Rectangle(Decimal(440), Decimal(330), Decimal(100),
                          Decimal(100)), 10),
            # fifth row
            LineArtFactory.arrow_left(
                Rectangle(Decimal(0), Decimal(440), Decimal(100),
                          Decimal(100))),
            LineArtFactory.arrow_right(
                Rectangle(Decimal(110), Decimal(440), Decimal(100),
                          Decimal(100))),
            LineArtFactory.arrow_up(
                Rectangle(Decimal(220), Decimal(440), Decimal(100),
                          Decimal(100))),
            LineArtFactory.arrow_down(
                Rectangle(Decimal(330), Decimal(440), Decimal(100),
                          Decimal(100))),
            LineArtFactory.sticky_note(
                Rectangle(Decimal(440), Decimal(440), Decimal(100),
                          Decimal(100))),
        ]

        colors = [
            X11Color("Red"),
            X11Color("Orange"),
            X11Color("Yellow"),
            X11Color("Green"),
            X11Color("Blue"),
            X11Color("Plum"),
        ]

        # add annotation
        for i, s in enumerate(shapes):
            doc.get_page(0).append_polygon_annotation(
                points=s,
                stroke_color=colors[i % len(colors)],
            )

        # attempt to store PDF
        with open(out_file, "wb") as out_file_handle:
            print("\twriting ..")
            PDF.dumps(out_file_handle, doc)

        # attempt to re-open PDF
        with open(out_file, "rb") as in_file_handle:
            print("\treading (2) ..")
            doc = PDF.loads(in_file_handle)

        return True
    def test_write_document(self):

        # create output directory if it does not exist yet
        if not self.output_dir.exists():
            self.output_dir.mkdir()

        # create document
        pdf = Document()

        # add page
        page = Page()
        pdf.append_page(page)
        layout = SingleColumnLayout(page)

        # title
        layout.add(
            Paragraph("Flowchart Line Art",
                      font_size=Decimal(20),
                      font_color=X11Color("Blue")))

        # table
        fixed_bb = Rectangle(Decimal(0), Decimal(0), Decimal(100),
                             Decimal(100))
        t = Table(number_of_rows=10, number_of_columns=6)
        t.add(
            Shape(
                LineArtFactory.flowchart_process(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_decision(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_document(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_predefined_document(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                # LineArtFactory.flowchart_multiple_documents(fixed_bb)
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_data(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))

        # captions
        t.add(Paragraph("Process"))
        t.add(Paragraph("Decision"))
        t.add(Paragraph("Document"))
        t.add(Paragraph("Predefined Document"))
        t.add(Paragraph("Multiple Documents"))
        t.add(Paragraph("Data"))

        # second row of shapes
        t.add(
            Shape(
                LineArtFactory.flowchart_predefined_process(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                # LineArtFactory.flowchart_stored_data(fixed_bb),
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_internal_storage(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_sequential_data(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                # LineArtFactory.flowchart_direct_data(fixed_bb),
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_manual_input(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))

        # captions
        t.add(Paragraph("Predefined Process"))
        t.add(Paragraph("Stored Data"))
        t.add(Paragraph("Internal Storage"))
        t.add(Paragraph("Sequential Data"))
        t.add(Paragraph("Direct Data"))
        t.add(Paragraph("Manual Input"))

        # third row of shapes
        t.add(
            Shape(
                LineArtFactory.flowchart_manual_operation(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_card(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_paper_tape(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                # LineArtFactory.flowchart_display(fixed_bb),
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_preparation(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_loop_limit(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))

        # captions
        t.add(Paragraph("Manual Operation"))
        t.add(Paragraph("Card"))
        t.add(Paragraph("Paper Tape"))
        t.add(Paragraph("Display"))
        t.add(Paragraph("Preparation"))
        t.add(Paragraph("Loop Limit"))

        # fourth row of shapes
        t.add(
            Shape(
                # LineArtFactory.flowchart_termination(fixed_bb),
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_collate(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                # LineArtFactory.flowchart_delay(fixed_bb),
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_extract(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_merge(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_or(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))

        # captions
        t.add(Paragraph("Termination"))
        t.add(Paragraph("Collate"))
        t.add(Paragraph("Delay"))
        t.add(Paragraph("Extract"))
        t.add(Paragraph("Merge"))
        t.add(Paragraph("Or"))

        # fifth row of shapes
        t.add(
            Shape(
                LineArtFactory.flowchart_sort(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_summing_junction(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.regular_n_gon(fixed_bb, 8),
                # LineArtFactory.flowchart_database(fixed_bb),
                fill_color=X11Color("White"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_on_page_reference(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_off_page_reference(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))
        t.add(
            Shape(
                LineArtFactory.flowchart_process_iso_9000(fixed_bb),
                fill_color=X11Color("Blue"),
                stroke_color=X11Color("Black"),
                line_width=Decimal(1),
            ))

        # captions
        t.add(Paragraph("Sort"))
        t.add(Paragraph("Summing Junction"))
        t.add(Paragraph("Database"))
        t.add(Paragraph("On Page Reference"))
        t.add(Paragraph("Off Page Reference"))
        t.add(Paragraph("Process ISO 9000"))

        t.set_padding_on_all_cells(Decimal(10), Decimal(10), Decimal(10),
                                   Decimal(10))
        layout.add(t)

        # determine output location
        out_file = self.output_dir / ("output.pdf")

        # attempt to store PDF
        with open(out_file, "wb") as in_file_handle:
            PDF.dumps(in_file_handle, pdf)

        # attempt to re-open PDF
        with open(out_file, "rb") as in_file_handle:
            PDF.loads(in_file_handle)