# 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",
)
Exemple #2
0
    # Creation of the output Presentation document :
    # presentation = Document_from_type('presentation')  # 092
    presentation = Document("presentation")

    # Presentation got a body in which content is stored
    presentation_body = presentation.body

    # For each image, we create a page in the presentation and display the image
    # and some text on this frame
    for image in images_pool:
        # add the file to the document
        uri = presentation.add_file(image.path)

        # Create an underlying page for the image and the text
        page = DrawPage("Page " + image.name)

        # Create a frame for the image
        image_frame = Frame.image_frame(
            image=uri,
            name=image.name,
            text="",  # Text over the image object
            size=(image.disp_w, image.disp_h),  # Display size of image
            anchor_type="page",
            page_number=None,
            position=(image.pos_x, image.pos_y),
            style=None,
        )

        # Append all the component
        page.append(image_frame)
Exemple #3
0
# 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")
    # weight = len(doc_source.get_part(uri))  # only for info
    # print "image %s , size in bytes: %s" % (uri, weight)
    part = doc_source.get_part(uri)  # actual image content
    name = uri.split("/")[-1]  # lets make a file name for image

    # Compute the display size of the image on the final page
    ratio = embedded_image_ratio(uri, part)
    max_border = 16.0  # max size of the greatest border, in cm
    a = max_border * ratio
    b = max_border
    if ratio > 1.0:
        a /= ratio
        b /= ratio

    # Create an underlying page for the image and the text
    page = DrawPage("page " + name)

    # Create a frame for the image
    image_frame = Frame.image_frame(
        image=uri,
        text="",  # Text over the image object
        size=("%scm" % a, "%scm" % b),  # Display size of image
        anchor_type="page",
        page_number=None,
        position=("3.5cm", "3.5 cm"),
        style=None,
    )

    # Add some text object somehere on the frame, with a text frame
    legend = "Image %s from Wikipedia document / %s" % (name, filename)
    text_frame = Frame.text_frame(
Exemple #5
0
# Making o lot of variations
variants = [10, 11, 14, 16, 20, 24, 32, 40, 44]
text_sz = [95, 80, 65, 50, 40, 30, 20, 10, 5]
for size in variants:
    variant_style = base_style.clone
    variant_style.set_attribute('style:name', 'Gloup%s' % size)
    variant_style.set_properties(area='text', size="%spt" % size)
    presentation.insert_style(variant_style)

count = 0

for blurb in lst:
    count += 1
    text = blurb
    name = "%s - %s" % (count, text[:10])
    page = DrawPage(name)
    # choosing some style:
    size = 48
    for i, max_size in enumerate(text_sz):
        if len(text) > max_size:
            size = variants[i]
            break

    text_frame = Frame.text_frame(
        text,
        size=('24cm', '2cm'),
        position=('2cm', '8cm'),
        style='Gloup%s' % size,
        text_style='Gloup%s' % size)

    page.append(text_frame)