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