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 addImage(self, data_box): format = 'PNG' image_file = tempfile.mkstemp(dir = ConfigurationManager.TEMPORARY_FOLDER, suffix = '.' + format)[1] data_box.image.save(image_file, format = format) x, y, width, height = data_box.getBoundsPrintSize(self.current_page_resolution) photo_frame = Frame(stylename=self.photo_style, x = '%sin' % x, y = '%sin' % y, width = '%sin' % width, height = '%sin' % height, anchortype='paragraph') self.current_page.addElement(photo_frame) location = self.document.addPicture(image_file) photo_frame.addElement(Image(href=location)) self.temp_images.append(image_file)
def addText(self, data_box): text = data_box.getText() frame_style = Style(name='FrameStyle', family = 'graphic') debug('Angle: ', 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))