def addText(self, data_box): text = data_box.getText() frame_style = Style(name='FrameStyle', family='graphic') debug('Angle: %s' % data_box.text_data.angle) angle = data_box.text_data.angle if angle: frame_style = Style(name='FrameStyleRotated', family='graphic') x, y, width, height = data_box.getBoundsPrintSize( self.current_page_resolution) frame = Frame(stylename=frame_style, width=str(width) + 'in', height=str(height) + 'in', x=str(x) + 'in', y=str(y) + 'in', anchortype='paragraph') if angle: frame.addAttribute( 'transform', 'rotate (%s) translate (%scm %scm)' % (abs(math.radians(angle)), x, y)) self.current_page.addElement(frame) textbox = TextBox() frame.addElement(textbox) for line in text.split('\n'): textbox.addElement( P(stylename=self.__handleFrameStyle(data_box.text_data), text=line))
def __handleFrameStyleRotated(self, text_data): style_name = 'box%s%s%s%s%sRotated' % (text_data.face, text_data.size, text_data.line_space, text_data.letter_space, text_data.justification) if not style_name in self.font_styles: frame_style = Style(name = style_name, family = 'paragraph') frame_style.addElement(ParagraphProperties(linespacing = '%spt' % text_data.line_space, textalign = self.convertTextAlign(text_data.justification))) frame_style.addElement(TextProperties(letterspacing = '%spt' % text_data.letter_space, fontstyle = self.convertFontStyle(text_data.style), fontweight = self.convertFontWeight(text_data.weight), fontsize = '%spt' % text_data.size, fontfamily = str(text_data.face))) self.document.automaticstyles.addElement(frame_style) self.font_styles.append(style_name) return style_name
def newPage(self, page_data): master_name = self.__handlePageMaster(page_data) page_style_name = '%sPage' % master_name if not page_style_name in self.page_styles: page_style = Style(name = page_style_name, family = 'paragraph', masterpagename = master_name) page_style.addElement(ParagraphProperties(breakbefore = 'page')) self.document.automaticstyles.addElement(page_style) new_page = P(stylename = page_style_name) self.document.text.addElement(new_page) return new_page
def __init__(self, name): self.name = name self.document = OpenDocumentText() self.current_page = None self.photo_style = Style(name="Photo", family="graphic") self.document.styles.addElement(self.photo_style) self.font_styles = [] self.page_layouts = [] self.page_masters = [] self.page_styles = [] self.temp_images = [] frame_style = Style(name='FrameStyle', family = 'graphic') frame_style.addElement(GraphicProperties(borderlinewidth='none')) self.document.styles.addElement(frame_style) frame_style_rotated = Style(name='FrameStyleRotated', family = 'graphic') frame_style_rotated.addElement(GraphicProperties(fill = 'none', stroke = 'none', verticalpos = 'from-top', verticalrel = 'paragraph')) self.document.automaticstyles.addElement(frame_style_rotated)