file_name = source[0] presentation = Document(file_name) presentation_body = presentation.body uri = presentation.add_file(options.image) width, height = make_image_size(options.image, float(options.size)) # Create a frame for the image image_frame = Frame( url=uri, name=file_name, text='', # Text over the image object size=(width, height), # Display size of image anchor_type='page', page_number=None, position=(pos_x, pos_y), style=None) image_frame.svg_title = title image_frame.svg_description = text # Append all the component i = start while True: slide = presentation_body.get_draw_page(position=i) # Create a frame for the image image_frame = Frame( url=uri, name=file_name,
# I want to write "Hello World" in the middle of the first page. from odfdo import Document, Frame, DrawPage document = Document("presentation") body = document.body page = DrawPage("page1", name="Page 1") body.append(page) text_frame = Frame( ["Hello", "World"], size=("7cm", "5cm"), position=("11cm", "8cm"), style="colored", text_style="big", )
# Heading heading = Header(1, text=filename) body.append(heading) path = join('samples', filename) mimetype, _ = guess_type(path) if mimetype is None: mimetype = 'application/octet-stream' if mimetype.startswith('image/'): # Add the image internal_name = 'Pictures/' + filename image = Image.open(path) width, height = image.size paragraph = Paragraph('Standard') # 72 ppp frame = Frame('frame_%d' % numero, 'Graphics', str(int(width / 72.0)) + 'in', str(int(height / 72.0)) + 'in') image = DrawImage(internal_name) frame.append(image) paragraph.append(frame) body.append(paragraph) # And store the data container = document.container with open(path, 'rb') as f: content = f.read() container.set_part(internal_name, content) elif mimetype in ('text/csv', 'text/comma-separated-values'): table = Table("table %d" % numero, style="Standard") csv = reader(open(path)) for line in csv:
# I want to write "Hello World" in the middle of the first page. from odfdo import Document, Frame, DrawPage document = Document('presentation') body = document.body page = DrawPage('page1', name="Page 1") body.append(page) text_frame = Frame(["Hello", "World"], size=('7cm', '5cm'), position=('11cm', '8cm'), style="colored", text_style="big")
print(' Version : %s' % __version__) print() print('Generating test_output/use_case2.odt ...') # Go document = Document('text') body = document.body # 0- The image # ------------ image = Image.open('samples/image.png') width, height = image.size paragraph = Paragraph(style="Standard") # 72 ppp frame = Frame('frame1', 'Graphics', str(int(width / 72.0)) + 'in', str(int(height / 72.0)) + 'in') internal_name = 'Pictures/image.png' image = DrawImage(internal_name) frame.append(image) paragraph.append(frame) body.append(paragraph) # And store the data container = document.container with open('samples/image.png', 'rb') as f: content = f.read() container.set_part(internal_name, content) # 1- Congratulations (=> style on paragraph) # ------------------------------------------