aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2014-11-12 16:09:39 +0100
committerMartin Vilcans <martin@librador.com>2014-11-12 16:10:12 +0100
commit2bbeaeb2cab56631a635379a0fbbf9c25da7920d (patch)
tree5454b3738e060b3d7058b208cb35bc5f95c35828
parent304d397c163338e3b6caaca9f729a6d5e72f0b3b (diff)
downloadscreenplain-2bbeaeb2cab56631a635379a0fbbf9c25da7920d.tar.gz
Don't count title page when numbering pages
-rw-r--r--screenplain/export/pdf.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/screenplain/export/pdf.py b/screenplain/export/pdf.py
index 6c2f1a6..13218f5 100644
--- a/screenplain/export/pdf.py
+++ b/screenplain/export/pdf.py
@@ -108,6 +108,7 @@ contact_style = ParagraphStyle(
class DocTemplate(BaseDocTemplate):
def __init__(self, *args, **kwargs):
+ self.has_title_page = kwargs.pop('has_title_page', False)
frame = Frame(
left_margin, bottom_margin, frame_width, frame_height,
id='normal',
@@ -122,7 +123,10 @@ class DocTemplate(BaseDocTemplate):
def handle_pageBegin(self):
self.canv.setFont('Courier', 12, leading=12)
- page = self.page + 1
+ if self.has_title_page:
+ page = self.page # self.page is 0 on first page
+ else:
+ page = self.page + 1
if page >= 2:
self.canv.drawRightString(
left_margin + frame_width,
@@ -218,6 +222,7 @@ def get_title_page_story(screenplay):
def to_pdf(screenplay, output_filename, template_constructor=DocTemplate):
story = get_title_page_story(screenplay)
+ has_title_page = bool(story)
for para in screenplay:
if isinstance(para, Dialog):
@@ -242,5 +247,6 @@ def to_pdf(screenplay, output_filename, template_constructor=DocTemplate):
doc = template_constructor(
output_filename,
pagesize=(page_width, page_height),
+ has_title_page=has_title_page
)
doc.build(story)