Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2013-11-27 05:33:12 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2013-11-27 05:33:12 (GMT)
commit3bd887ef78722b6187ea7b53cd1266f6ff6124a3 (patch)
treed609d4be45dd069385c96f1e168ff86878f9a3ec
parentea694914306e1062a848198184acc7e215c4a672 (diff)
parent81a0b6197fbda041934cceb6f87be27ba7a419b5 (diff)
Merge branch 'master' of git.sugarlabs.org:fototoon/mainline
-rw-r--r--historietaactivity.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/historietaactivity.py b/historietaactivity.py
index b367981..16b334f 100644
--- a/historietaactivity.py
+++ b/historietaactivity.py
@@ -266,20 +266,30 @@ class HistorietaActivity(activity.Activity):
_('A image was created in the Journal'))
def _save_as_pdf(self, widget):
- if not len(self.page.boxs) > 1:
- return
file_name = os.path.join(self.get_activity_root(), 'instance',
'tmp-%i.pdf' % time.time())
file_obj = open(file_name, 'w')
- surface = cairo.PDFSurface(file_obj, self.page.boxs[1].width,
- self.page.boxs[1].height)
+ page_width = self.page.boxs[1].width
+ page_height = self.page.boxs[1].height
+
+ surface = cairo.PDFSurface(file_obj, page_width, page_height)
+
context = cairo.Context(surface)
- for box in self.page.boxs[1:]:
+ for box in self.page.boxs[0:]:
+ context.save()
+ if box.width != page_width:
+ # for the first box, scale and center
+ scale = float(page_width) / float(box.width)
+ top_margin = (page_height - box.height) / 2
+ context.translate(0, top_margin)
+ context.scale(scale, scale)
+
box.draw_in_context(context)
context.show_page()
+ context.restore()
surface.finish()
file_obj.close()