分割が可能なReportLabのためのFlowableを作成しようとしています。ドキュメンテーションの私の理解に基づいて、私はフローティングを分割する関数split(self, aW, aH)
を定義する必要があります。しかし、私は解決できない次のエラーを受けています。ReportLabをフローティングに分割する
シンプルフロアブル:
class MPGrid (Flowable):
def __init__(self, height=1*cm, width=None):
self.height = height
self.width = None
def wrap(self, aW, aH):
self.width = aW
return (aW, self.height)
def split(self, aW, aH):
if aH >= self.height:
return [self]
else:
return [MPGrid(aH, aW), MPGrid(self.height - aH, None)]
def draw(self):
if not self.width:
from reportlab.platypus.doctemplate import LayoutError
raise LayoutError('No Width Defined')
c = self.canv
c.saveState()
c.rect(0, 0, self.width, self.height)
c.restoreState()
文書で使用され、分割を必要とは、次のエラーを生成します。
reportlab.platypus.doctemplate.LayoutError: Splitting error(n==2) on page 4 in
<MPGrid at 0x102051c68 frame=col1>...
S[0]=<MPGrid at 0x102043ef0 frame=col1>...
このフロアブルは、固定の高さであるべきであり、それが大きすぎる場合使用可能な高さについては、高さを消費するように分割され、次のフレームで固定高さのアラームが消費されます。
私は間違っていますが、これはあまり役に立たないエラーの原因です。