Esempio n. 1
0
 def test_insert_image(self):
     body = self.body.clone()
     path = 'a/path'
     image = odf_create_image(path)
     frame = odf_create_frame(u"Image Frame", size=('0cm', '0cm'),
                              style='Graphics')
     frame.append(image)
     body.get_frame().insert(frame, NEXT_SIBLING)
     element = body.get_image(name=u"Image Frame")
     self.assertEqual(element.get_attribute('xlink:href'), path)
     element = body.get_image(position=1)
     self.assertEqual(element.get_attribute('xlink:href'), path)
Esempio n. 2
0
 def test_insert_image(self):
     body = self.body.clone()
     path = 'a/path'
     image = odf_create_image(path)
     frame = odf_create_frame(u"Image Frame",
                              size=('0cm', '0cm'),
                              style='Graphics')
     frame.append(image)
     body.get_frame().insert(frame, NEXT_SIBLING)
     element = body.get_image(name=u"Image Frame")
     self.assertEqual(element.get_attribute('xlink:href'), path)
     element = body.get_image(position=1)
     self.assertEqual(element.get_attribute('xlink:href'), path)
Esempio n. 3
0
 def test_create_image(self):
     image = odf_create_image(self.path)
     expected = ('<draw:image xlink:href="%s" xlink:type="simple" '
                 'xlink:show="embed" xlink:actuate="onLoad"/>' % self.path)
     self.assertEqual(image.serialize(), expected)
Esempio n. 4
0
# Go
document = odf_new_document('text')
body = document.get_body()

# 1- The image
# ------------
image = Image.open('samples/image.png')
width, height = image.size
paragraph = odf_create_paragraph(style=u"Standard")
# 72 ppp
frame = odf_create_frame('frame1', 'Graphics',
                         str(width / 72.0) + 'in',
                         str(height / 72.0) + 'in')
internal_name = 'Pictures/image.png'
image = odf_create_image(internal_name)
frame.append(image)
paragraph.append(frame)
body.append(paragraph)

# And store the data
container = document.container
container.set_part(internal_name, open('samples/image.png').read())

# 2- Congratulations (=> style on paragraph)
# ------------------------------------------
heading = odf_create_heading(1, text=u'Congratulations !')
body.append(heading)

# The style
style = odf_create_style('paragraph',
Esempio n. 5
0
# Go
document = odf_new_document('text')
body = document.get_body()

# 0- The image
# ------------
image = Image.open('samples/image.png')
width, height = image.size
paragraph = odf_create_paragraph(style=u"Standard")
# 72 ppp
frame = odf_create_frame('frame1', 'Graphics',
                         str(width / 72.0) + 'in',
                         str(height / 72.0) + 'in')
internal_name = 'Pictures/image.png'
image = odf_create_image(internal_name)
frame.append(image)
paragraph.append(frame)
body.append(paragraph)

# And store the data
container = document.container
container.set_part(internal_name, open('samples/image.png').read())


# 1- Congratulations (=> style on paragraph)
# ------------------------------------------
heading = odf_create_heading(1, text=u'Congratulations !')
body.append(heading)

# The style
Esempio n. 6
0
 def test_create_image(self):
     image = odf_create_image(self.path)
     expected = ('<draw:image xlink:href="%s" xlink:type="simple" '
             'xlink:show="embed" xlink:actuate="onLoad"/>' % self.path)
     self.assertEqual(image.serialize(), expected)
Esempio n. 7
0
 def test_create_image(self):
     image = odf_create_image(self.path)
     expected = '<draw:image xlink:href="%s"/>' % self.path
     self.assertEqual(image.serialize(), expected)