def event_occurred(self, event: Event) -> None: if isinstance(event, TextRenderEvent): self.render_text(event) if isinstance(event, BeginPageEvent): self.begin_page(event.get_page()) if isinstance(event, EndPageEvent): self.end_page(event.get_page())
def _event_occurred(self, event: Event) -> None: if isinstance(event, ChunkOfTextRenderEvent): self._render_text(event) if isinstance(event, BeginPageEvent): self._begin_page(event.get_page()) if isinstance(event, EndPageEvent): self._end_page(event.get_page())
def event_occurred(self, event: Event) -> None: if isinstance(event, ChunkOfTextRenderEvent): self.chunks_of_text.append(event) if isinstance(event, BeginPageEvent): self.current_page = event.get_page() self.current_page_number += 1 self.chunks_of_text = [] if isinstance(event, EndPageEvent): self._end_page(event.get_page())
def event_occurred(self, event: Event) -> None: if isinstance(event, TextRenderEvent): assert isinstance(event, TextRenderEvent) space = Rectangle( event.get_baseline().x0, event.get_baseline().y0, event.get_baseline().x1, Decimal(12), ) # TODO: height self._mark_as_unavailable(space)
def event_occurred(self, event: Event): if isinstance(event, ChunkOfTextRenderEvent): assert isinstance(event, ChunkOfTextRenderEvent) self.measurands.append( { "text": event.text, "x0": float(event.get_bounding_box().x), "x1": float( event.get_bounding_box().x + event.get_bounding_box().width ), "y": float(event.get_baseline().y), "length": float(event.get_baseline().width), } )
def event_occurred(self, event: Event): if isinstance(event, TextRenderEvent): assert isinstance(event, TextRenderEvent) self.measurands.append({ "text": event.get_text(), "x0": float(event.get_baseline().x0), "x1": float(event.get_baseline().x1), "y": float(event.get_baseline().y0), "length": float(event.get_baseline().length()), })
def event_occurred(self, event: Event) -> None: if isinstance(event, BeginPageEvent): self._begin_page(event.get_page()) if isinstance(event, TextRenderEvent): self._render_text(event) if isinstance(event, ImageRenderEvent): self._render_image(event)
def event_occurred(self, event: Event) -> None: if isinstance(event, BeginPageEvent): self._begin_page(event.get_page()) elif isinstance(event, TitleRenderEvent): self._render_title(event) elif isinstance(event, BulletListRenderEvent): self._render_bullet_list(event) elif isinstance(event, OrderedListRenderEvent): self._render_ordered_list(event) elif isinstance(event, ParagraphRenderEvent): self._render_paragraph(event)
def _event_occurred(self, event: Event) -> None: # BeginPageEvent if isinstance(event, BeginPageEvent): self.page_nr += Decimal(1) self.page = event.get_page() self._begin_page( self.page_nr, self.page.get_page_info().get_width() or self.default_page_width, self.page.get_page_info().get_height() or self.default_page_height, ) # ImageRenderEvent if isinstance(event, ImageRenderEvent): assert self.page is not None self._render_image( self.page_nr, self.page.get_page_info().get_width() or self.default_page_width, self.page.get_page_info().get_height() or self.default_page_height, event.get_x(), event.get_y(), event.get_width(), event.get_height(), event.get_image(), ) # ChunkOfTextRenderEvent if isinstance(event, ChunkOfTextRenderEvent): assert self.page is not None font_name_as_str = "Helvetica" if event.font.get_font_name(): font_name_as_str = str(event.font.get_font_name()) self._render_text( self.page_nr, self.page.get_page_info().get_width() or self.default_page_width, self.page.get_page_info().get_height() or self.default_page_height, event.get_baseline().get_x(), event.get_baseline().get_y(), event.font_color, event.font_size, font_name_as_str.replace("#20", " ").replace( ",Bold", "").replace(",bold", "").replace("Bold", "").replace( "bold", "").replace(",Italic", "").replace( ",italic", "").replace("Italic", "").replace("italic", ""), "BOLD" in font_name_as_str.upper(), "ITALIC" in font_name_as_str.upper(), event.text, )
def event_occurred(self, event: Event) -> None: if isinstance(event, BeginPageEvent): self._begin_page(event.get_page())
def event_occurred(self, event: Event) -> None: if isinstance(event, ChunkOfTextRenderEvent): assert isinstance(event, ChunkOfTextRenderEvent) bb: typing.Optional[Rectangle] = event.get_bounding_box() if bb is not None: self._mark_as_unavailable(bb)
def event_occurred(self, event: Event) -> None: if isinstance(event, ParagraphRenderEvent): t = event.get_text() print(t)