From eb0c2264f140de74670f1fc52d31ced0e1dcee3c Mon Sep 17 00:00:00 2001 From: Peter Nerlich Date: Fri, 3 Apr 2026 15:54:27 +0200 Subject: [PATCH 1/2] add metadata to pdf --- screenplain/export/pdf.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/screenplain/export/pdf.py b/screenplain/export/pdf.py index 089382a..4b2ae0b 100644 --- a/screenplain/export/pdf.py +++ b/screenplain/export/pdf.py @@ -4,6 +4,7 @@ import sys import os +import re from reportlab import platypus from reportlab.lib import colors, pagesizes @@ -509,6 +510,38 @@ def add_lines(story, attribute, style, space_before=0): return story +def pdf_metadata(screenplay): + title_lines = screenplay.get_rich_attribute("Title") + author_lines = [ + *screenplay.get_rich_attribute("Author"), + *screenplay.get_rich_attribute("Authors"), + ] + subject_lines = screenplay.get_rich_attribute("Subject") + creator_lines = screenplay.get_rich_attribute("Creator") + producer_lines = screenplay.get_rich_attribute("Producer") + keywords_lines = screenplay.get_rich_attribute("Keywords") + + lang_lines = [ + *screenplay.get_rich_attribute("Lang"), + *screenplay.get_rich_attribute("Language"), + ] + + return { + "title": ' '.join([str(line) for line in title_lines]) or None, + "subject": ' '.join([str(line) for line in subject_lines]) or None, + "author": ', '.join([str(line) for line in author_lines]) or None, + "creator": ' '.join([str(line) for line in creator_lines]) or None, + "producer": ' '.join([str(line) for line in producer_lines]) or None, + "keywords": [ + word.strip() + for line in keywords_lines + for word in re.split('[,;/]', str(line)) + if word.strip() + ], + "lang": ' '.join([str(line) for line in lang_lines]) or None, + } + + def to_pdf( screenplay, output_filename, template_constructor=DocTemplate, @@ -540,10 +573,12 @@ def to_pdf( # Ignore unknown types pass + meta = pdf_metadata(screenplay) doc = template_constructor( output_filename, pagesize=(settings.page_width, settings.page_height), settings=settings, - has_title_page=has_title_page + has_title_page=has_title_page, + **meta, ) doc.build(story) From 2e9f7bbca82d4b3bd71cda68a7ae1a6d06540928 Mon Sep 17 00:00:00 2001 From: Peter Nerlich Date: Fri, 3 Apr 2026 22:56:55 +0200 Subject: [PATCH 2/2] don't set creator or producer from .fountain --- screenplain/export/pdf.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/screenplain/export/pdf.py b/screenplain/export/pdf.py index 4b2ae0b..07edc55 100644 --- a/screenplain/export/pdf.py +++ b/screenplain/export/pdf.py @@ -517,8 +517,6 @@ def pdf_metadata(screenplay): *screenplay.get_rich_attribute("Authors"), ] subject_lines = screenplay.get_rich_attribute("Subject") - creator_lines = screenplay.get_rich_attribute("Creator") - producer_lines = screenplay.get_rich_attribute("Producer") keywords_lines = screenplay.get_rich_attribute("Keywords") lang_lines = [ @@ -530,8 +528,6 @@ def pdf_metadata(screenplay): "title": ' '.join([str(line) for line in title_lines]) or None, "subject": ' '.join([str(line) for line in subject_lines]) or None, "author": ', '.join([str(line) for line in author_lines]) or None, - "creator": ' '.join([str(line) for line in creator_lines]) or None, - "producer": ' '.join([str(line) for line in producer_lines]) or None, "keywords": [ word.strip() for line in keywords_lines