Skip to content

Commit

Permalink
- Added title, subject, author, and creator attribute…
Browse files Browse the repository at this point in the history
…s to

  ``document`` element. Those are set as PDF annotations, which are now
  commonly used to hint viewers window titles, etc. (Those fields are not
  available in RML2PDF.)
  • Loading branch information
strichter committed Sep 3, 2013
1 parent f575b53 commit c628762
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
7 changes: 5 additions & 2 deletions CHANGES.rst
Expand Up @@ -2,10 +2,13 @@
CHANGES
=======

2.2.2 (unreleased)
2.3.0 (unreleased)
------------------

- Nothing changed yet.
- Added ``title``, ``subject``, ``author``, and ``creator`` attributes to
``document`` element. Those are set as PDF annotations, which are now
commonly used to hint viewers window titles, etc. (Those fields are not
available in RML2PDF.)


2.2.1 (2013-08-06)
Expand Down
2 changes: 1 addition & 1 deletion buildout.cfg
Expand Up @@ -6,7 +6,7 @@ parts = test coverage-test coverage-report
scripts python

[test]
recipe = zc.recipe.testrunner
recipe = zc.recipe.testrunner>=2.0
eggs = z3c.rml [test]

[coverage-test]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -43,7 +43,7 @@ def alltests():

setup (
name='z3c.rml',
version='2.2.2.dev0',
version='2.3.0.dev0',
author="Stephan Richter and the Zope Community",
author_email="zope-dev@zope.org",
description="An alternative implementation of RML",
Expand Down
27 changes: 27 additions & 0 deletions src/z3c/rml/document.py
Expand Up @@ -576,6 +576,26 @@ class IDocument(interfaces.IRMLDirectiveSignature):
u'file was provided.'),
required=True)

title = attr.String(
title=u'Title',
description=(u'The "Title" annotation for the PDF document.'),
required=False)

subject = attr.String(
title=u'Subject',
description=(u'The "Subject" annotation for the PDF document.'),
required=False)

author = attr.String(
title=u'Author',
description=(u'The "Author" annotation for the PDF document.'),
required=False)

creator = attr.String(
title=u'Creator',
description=(u'The "Creator" annotation for the PDF document.'),
required=False)

debug = attr.Boolean(
title=u'Debug',
description=u'A flag to activate the debug output.',
Expand Down Expand Up @@ -644,6 +664,13 @@ def _initCanvas(self, canvas):
for name, option in DocInit.viewerOptions.items():
if getattr(self, name) is not None:
canvas.setViewerPreference(option, getattr(self, name))
# Setting annotations.
data = dict(self.getAttributeValues(
select=('title', 'subject', 'author', 'creator')))
canvas.setTitle(data.get('title'))
canvas.setSubject(data.get('subject'))
canvas.setAuthor(data.get('author'))
canvas.setCreator(data.get('creator'))

def process(self, outputFile=None, maxPasses=2):
"""Process document"""
Expand Down
Binary file modified src/z3c/rml/rml-reference.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions src/z3c/rml/rml.dtd
@@ -1,6 +1,10 @@

<!ELEMENT document (docinit?,stylesheet?,template?,story?,pageInfo?,pageDrawing*)>
<!ATTLIST document filename CDATA #REQUIRED>
<!ATTLIST document title CDATA #IMPLIED>
<!ATTLIST document subject CDATA #IMPLIED>
<!ATTLIST document author CDATA #IMPLIED>
<!ATTLIST document creator CDATA #IMPLIED>
<!ATTLIST document debug CDATA #IMPLIED>
<!ATTLIST document compression CDATA #IMPLIED>
<!ATTLIST document invariant CDATA #IMPLIED>
Expand Down

0 comments on commit c628762

Please sign in to comment.