Skip to content

Commit

Permalink
* KeepInFrame has a bug in ReportLab 2.0 not allowing maxHeight to be
Browse files Browse the repository at this point in the history
  None, even though the wrap() method does the right thing and can handle 
  None and 0, both values disallowed.

* Make sure that we strip the <?xml ?> line only when dealing with a 
  unicode string.
  • Loading branch information
strichter committed Apr 4, 2007
1 parent b4264de commit 4a5bf64
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/z3c/rml/flowable.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class IKeepInFrame(interfaces.IRMLDirectiveSignature):

class KeepInFrame(Flowable):
signature = IKeepInFrame
klass = reportlab.platypus.flowables.KeepInFrame
klass = platypus.KeepInFrame
attrMapping = {'onOverflow': 'mode', 'id': 'name'}

def process(self):
Expand Down
18 changes: 18 additions & 0 deletions src/z3c/rml/platypus.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@

from z3c.rml import interfaces

# Fix problem with reportlab 2.0
class KeepInFrame(reportlab.platypus.flowables.KeepInFrame):

def __init__(self, maxWidth, maxHeight, content=[], mergeSpace=1,
mode='shrink', name=''):
self.name = name
self.maxWidth = maxWidth
self.maxHeight = maxHeight
self.mode = mode
assert mode in ('error','overflow','shrink','truncate'), \
'%s invalid mode value %s' % (self.identity(),mode)
# This is an unnecessary check, since wrap() handles None just fine!
#assert maxHeight>=0, \
# '%s invalid maxHeight value %s' % (self.identity(),maxHeight)
if mergeSpace is None: mergeSpace = overlapAttachedSpace
self.mergespace = mergeSpace
self._content = content


class BaseFlowable(reportlab.platypus.flowables.Flowable):
def __init__(self, *args, **kw):
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/rml/rml2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def parseString(xml, removeEncodingLine=True):
if removeEncodingLine:
if isinstance(xml, unicode) and removeEncodingLine:
# RML is a unicode string, but oftentimes documents declare their
# encoding using <?xml ...>. Unfortuantely, I cannot tell lxml to
# ignore that directive. Thus we remove it.
Expand Down

0 comments on commit 4a5bf64

Please sign in to comment.