From 7ddd8af531a4bb335758122b06fae42ed7b603a9 Mon Sep 17 00:00:00 2001 From: Andrew Benson Date: Fri, 26 Apr 2019 03:15:00 +0200 Subject: export/pdf: make sure title page is centered. Closes #50. --- screenplain/export/pdf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/screenplain/export/pdf.py b/screenplain/export/pdf.py index 6955616..ccc7cf1 100644 --- a/screenplain/export/pdf.py +++ b/screenplain/export/pdf.py @@ -17,6 +17,7 @@ from reportlab.platypus import ( Paragraph, Frame, PageTemplate, + NextPageTemplate, Spacer, ) from reportlab import platypus @@ -43,6 +44,7 @@ right_margin = page_width - left_margin - frame_width top_margin = 1 * inch bottom_margin = page_height - top_margin - frame_height +title_frame_width = page_width - left_margin - left_margin default_style = ParagraphStyle( 'default', @@ -118,7 +120,13 @@ class DocTemplate(BaseDocTemplate): id='normal', leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0 ) + title_frame = Frame( + left_margin, bottom_margin, title_frame_width, frame_height, + id='title', + leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0 + ) pageTemplates = [ + PageTemplate(id='title', frames=[title_frame]), PageTemplate(id='standard', frames=[frame]) ] BaseDocTemplate.__init__( @@ -237,6 +245,8 @@ def get_title_page_story(screenplay): story.append(Spacer(frame_width, middle_space)) story += lower_story + story.append(NextPageTemplate('standard')) + story.append(platypus.PageBreak()) return story -- cgit