"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/test_platypus_paragraphs.py" between
reportlab-3.5.65.tar.gz and reportlab-3.5.66.tar.gz

About: ReportLab generates high-quality dynamic PDF documents/charts in real-time & high volumes from any data source (commercial version also available). f: office t: PDF report "data graphics" charts

test_platypus_paragraphs.py  (reportlab-3.5.65):test_platypus_paragraphs.py  (reportlab-3.5.66)
skipping to change at line 282 skipping to change at line 282
p.drawOn(c, cm, 2*cm) p.drawOn(c, cm, 2*cm)
xcode = ['q', '1 0 0 1 28.34646 56.69291 cm', 'q', 'q', '110 0 0 44 0 -1 6 cm', '/FormXob.00cb676cb2b2da8ec875fe2c13cf2496 Do', 'Q', 'BT 1 0 0 1 0 2 Tm 1 2 TL 110 0 Td /F1 10 Tf 12 TL T* -110 0 Td ET', 'Q', 'Q'] xcode = ['q', '1 0 0 1 28.34646 56.69291 cm', 'q', 'q', '110 0 0 44 0 -1 6 cm', '/FormXob.00cb676cb2b2da8ec875fe2c13cf2496 Do', 'Q', 'BT 1 0 0 1 0 2 Tm 1 2 TL 110 0 Td /F1 10 Tf 12 TL T* -110 0 Td ET', 'Q', 'Q']
xwh = (28.346456692913385, 12) xwh = (28.346456692913385, 12)
ocode = c._code[cx0:] ocode = c._code[cx0:]
c.showPage() c.showPage()
c.save() c.save()
self.assertEqual((owh,ocode),(xwh,xcode), self.assertEqual((owh,ocode),(xwh,xcode),
"\n(owh,ocode)=%r\nfor test_lele_img.pdf doesn't match expected\ n(xwh,xcode)=%r" %( "\n(owh,ocode)=%r\nfor test_lele_img.pdf doesn't match expected\ n(xwh,xcode)=%r" %(
(xwh,xcode),(owh,ocode))) (xwh,xcode),(owh,ocode)))
DEJAVUSANS = ('DejaVuSans','DejaVuSans-Bold','DejaVuSans-Oblique','DejaVuSans-Bo
ldOblique')
def haveDejaVu():
from reportlab.pdfbase.ttfonts import TTFont
for x in DEJAVUSANS:
try:
TTFont(x,x+'.ttf')
except:
return False
return True
class ParagraphSplitTestCase(unittest.TestCase): class ParagraphSplitTestCase(unittest.TestCase):
"Test multi-page splitting of paragraphs (eyeball-test)." "Test multi-page splitting of paragraphs (eyeball-test)."
def test0(self): def test0(self):
"ParagraphSplitTestCase.test0" "ParagraphSplitTestCase.test0"
# Build story. # Build story.
story = [] story = []
styleSheet = getSampleStyleSheet() styleSheet = getSampleStyleSheet()
bt = styleSheet['BodyText'] bt = styleSheet['BodyText']
skipping to change at line 692 skipping to change at line 702
\xd7\x93\xd7\xa8\xd7\x9b\xd7\x94 \xd7\xa9\xd7\x99\xd7\xaa\xd7\x95\xd7\xa 4\xd7\x99\xd7\xaa \xd7\x93\xd7\xa8\xd7\x9b\xd7\x94 \xd7\xa9\xd7\x99\xd7\xaa\xd7\x95\xd7\xa 4\xd7\x99\xd7\xaa
\xd7\x90\xd7\xaa\xd7\x94 \xd7\x93\xd7\xaa.''' \xd7\x90\xd7\xaa\xd7\x94 \xd7\x93\xd7\xaa.'''
gif = os.path.join(testsFolder,'pythonpowered.gif') gif = os.path.join(testsFolder,'pythonpowered.gif')
heading = Paragraph(b'\xd7\x96\xd7\x95\xd7\x94\xd7\x99 \xd7\x9b\xd7\x95\ xd7\xaa\xd7\xa8\xd7\xaa',h3) heading = Paragraph(b'\xd7\x96\xd7\x95\xd7\x94\xd7\x99 \xd7\x9b\xd7\x95\ xd7\xaa\xd7\xa8\xd7\xaa',h3)
story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text,bt)])) story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text,bt)]))
heading = Paragraph(b'\xd7\x96\xd7\x95\xd7\x94\xd7\x99 \xd7\x9b\xd7\x95\ xd7\xaa\xd7\xa8\xd7\xaa',h3) heading = Paragraph(b'\xd7\x96\xd7\x95\xd7\x94\xd7\x99 \xd7\x9b\xd7\x95\ xd7\xaa\xd7\xa8\xd7\xaa',h3)
story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text1,bt)]) ) story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text1,bt)]) )
doc = MyDocTemplate(outputfile('test_platypus_imageandflowables_rtl.pdf' ),showBoundary=1) doc = MyDocTemplate(outputfile('test_platypus_imageandflowables_rtl.pdf' ),showBoundary=1)
doc.multiBuild(story) doc.multiBuild(story)
@unittest.skipUnless(rtlSupport and haveDejaVu(),'s')
def test2_RTL(self):
'''example & bugfix contributed by Moshe Uminer < mosheduminer at gmail.
com >'''
from reportlab.platypus import Paragraph, PageBreak
from reportlab.lib.enums import TA_JUSTIFY, TA_RIGHT, TA_CENTER, TA_LEFT
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.pagesizes import LETTER
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.lib.colors import toColor
pdfmetrics.registerFont(TTFont("DejaVuSans", "DejaVuSans.ttf"))
text = u'\u05e9\u05dc\u05d5\u05dd! \u05d6\u05d5 \u05ea\u05d4\u05d9\u05d4
\u05e4\u05e1\u05e7\u05d4 \u05e9\u05d4\u05e9\u05d5\u05e8\u05d4 \u05d4\u05d0\u05d
7\u05e8\u05d5\u05e0\u05d4 \u05e9\u05dc\u05d4 \u05dc\u05d0 \u05ea\u05d5\u05e6\u05
d3\u05e7 \u05db\u05d4\u05dc\u05db\u05d4.'
text = u' '.join((text,text))
doc = SimpleDocTemplate(
outputfile("test_platypus_paragraphs_rtl_2.pdf"),
pagesize=LETTER,
rightMargin=72,
leftMargin=72,
topMargin=72,
bottomMargin=72,
)
styles = getSampleStyleSheet()
hebrew_j = ParagraphStyle(
parent=styles["Normal"],
name="NormalHebrew",
wordWrap="RTL",
alignment=TA_JUSTIFY,
fontName="DejaVuSans",
fontSize=14,
underlineWidth=0.5,
underlineColor=toColor('red'),
strikeWidth=0.4,
strikeColor=toColor('orange'),
)
latin = hebrew_j.clone('latin',alignment=TA_LEFT,wordWrap='LTR')
hebrew_r = hebrew_j.clone('nhr', alignment=TA_RIGHT)
hebrew_rd = hebrew_r.clone('nhrd', endDots='.')
hebrew_jd = hebrew_j.clone('nhjd', endDots='.')
hebrew_c = hebrew_j.clone('nhc', alignment=TA_CENTER)
hebrew_cd = hebrew_c.clone('nhc', endDots='.')
rtext = text.replace(u'\u05db\u05d4\u05dc\u05db\u05d4',u'<span color=red
>\u05db\u05d4\u05dc\u05db\u05d4</span>')
_utext = u''.join((u'<u>',text,u'</u>'))
utext = u''.join(('<u color=green>',text,'</u>'))
stext = u''.join(('<strike>',text,'</strike>'))
urtext = u''.join(('<u color=blue>',rtext,'</u>'))
srtext = u''.join(('<strike color=magenta>',rtext,'</strike>'))
flowables = [
Paragraph('justified',latin),
Paragraph(text, hebrew_j),
Paragraph(_utext, hebrew_j), #single frag takes defaults
Paragraph(stext, hebrew_j), #single frag takes defaults
Paragraph(utext, hebrew_j),
Paragraph(rtext, hebrew_j),
Paragraph(urtext, hebrew_j),
Paragraph(srtext, hebrew_j),
Paragraph('right',latin),
Paragraph(text, hebrew_r),
Paragraph(_utext, hebrew_r), #single frag takes defaults
Paragraph(stext, hebrew_r), #single frag takes defaults
Paragraph(utext, hebrew_r),
Paragraph(rtext, hebrew_r),
Paragraph(urtext, hebrew_r),
Paragraph(srtext, hebrew_r),
Paragraph('center',latin),
Paragraph(text, hebrew_c),
Paragraph(_utext, hebrew_c), #single frag takes defaults
Paragraph(stext, hebrew_c), #single frag takes defaults
Paragraph(utext, hebrew_c),
Paragraph(rtext, hebrew_c),
Paragraph(urtext, hebrew_c),
Paragraph(srtext, hebrew_c),
PageBreak(),
Paragraph('justified dots',latin),
Paragraph(text, hebrew_jd),
Paragraph(_utext, hebrew_jd), #single frag takes defaults
Paragraph(stext, hebrew_jd), #single frag takes defaults
Paragraph(utext, hebrew_jd),
Paragraph(rtext, hebrew_jd),
Paragraph(urtext, hebrew_jd),
Paragraph(srtext, hebrew_jd),
Paragraph('right dots',latin),
Paragraph(text, hebrew_rd),
Paragraph(_utext, hebrew_rd), #single frag takes defaults
Paragraph(stext, hebrew_rd), #single frag takes defaults
Paragraph(utext, hebrew_rd),
Paragraph(rtext, hebrew_rd),
Paragraph(urtext, hebrew_rd),
Paragraph(srtext, hebrew_rd),
Paragraph('center dots',latin),
Paragraph(text, hebrew_cd),
Paragraph(_utext, hebrew_cd), #single frag takes defaults
Paragraph(stext, hebrew_cd), #single frag takes defaults
Paragraph(utext, hebrew_cd),
Paragraph(rtext, hebrew_cd),
Paragraph(urtext, hebrew_cd),
Paragraph(srtext, hebrew_cd),
]
doc.build(flowables)
def test_splitJustBug(self): def test_splitJustBug(self):
"""test that justified paragraphs with </br>last line split properly """test that justified paragraphs with </br>last line split properly
bug reported by Niharika Singh <nsingh@shoobx.com> bug reported by Niharika Singh <nsingh@shoobx.com>
""" """
measures = [] measures = []
def _odW(canv,name,label): def _odW(canv,name,label):
measures.append((label,canv._curr_tx_info['cur_x'])) measures.append((label,canv._curr_tx_info['cur_x']))
text = '''<para><onDraw name="_odW" label="start"/>First line<onDraw nam e="_odW" label="end"/><br/><onDraw name="_odW" label="start"/>Second line<onDraw name="_odW" label="end"/><br/><onDraw name="_odW" label="start"/>split here<onD raw name="_odW" label="end"/><br/><onDraw name="_odW" label="start"/>Third line should not be justified<onDraw name="_odW" label="end"/><br/></para>''' text = '''<para><onDraw name="_odW" label="start"/>First line<onDraw nam e="_odW" label="end"/><br/><onDraw name="_odW" label="start"/>Second line<onDraw name="_odW" label="end"/><br/><onDraw name="_odW" label="start"/>split here<onD raw name="_odW" label="end"/><br/><onDraw name="_odW" label="start"/>Third line should not be justified<onDraw name="_odW" label="end"/><br/></para>'''
normal = getSampleStyleSheet()['BodyText'] normal = getSampleStyleSheet()['BodyText']
normal.fontName = "Helvetica" normal.fontName = "Helvetica"
skipping to change at line 1339 skipping to change at line 1457
normalCJK = ParagraphStyle('normalCJK', parent=normal, wordWrap = 'CJK') normalCJK = ParagraphStyle('normalCJK', parent=normal, wordWrap = 'CJK')
a(Paragraph('H=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif " width="0.57in" height="10%%" />'%dict(testsFolder=testsFolder), normalCJK)) a(Paragraph('H=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif " width="0.57in" height="10%%" />'%dict(testsFolder=testsFolder), normalCJK))
a(Paragraph('H=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif " width="0.57in" height="50%%" />'%dict(testsFolder=testsFolder), normalCJK)) a(Paragraph('H=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif " width="0.57in" height="50%%" />'%dict(testsFolder=testsFolder), normalCJK))
a(Paragraph('H=100%% <img src="%(testsFolder)s/../docs/images/testimg.gi f" width="0.57in" height="100%%" />'%dict(testsFolder=testsFolder), normalCJK)) a(Paragraph('H=100%% <img src="%(testsFolder)s/../docs/images/testimg.gi f" width="0.57in" height="100%%" />'%dict(testsFolder=testsFolder), normalCJK))
a(Paragraph('H=100%% W=10%% <img src="%(testsFolder)s/../docs/images/tes timg.gif" width="10%%" height="100%%" />'%dict(testsFolder=testsFolder), normalC JK)) a(Paragraph('H=100%% W=10%% <img src="%(testsFolder)s/../docs/images/tes timg.gif" width="10%%" height="100%%" />'%dict(testsFolder=testsFolder), normalC JK))
a(Paragraph('H=100%% W=50%% <img src="%(testsFolder)s/../docs/images/tes timg.gif" width="50%%" height="100%%" />'%dict(testsFolder=testsFolder), normalC JK)) a(Paragraph('H=100%% W=50%% <img src="%(testsFolder)s/../docs/images/tes timg.gif" width="50%%" height="100%%" />'%dict(testsFolder=testsFolder), normalC JK))
a(Paragraph('H=50%% W=50%% <img src="%(testsFolder)s/../docs/images/test img.gif" width="50%%" height="50%%" />'%dict(testsFolder=testsFolder), normalCJK )) a(Paragraph('H=50%% W=50%% <img src="%(testsFolder)s/../docs/images/test img.gif" width="50%%" height="50%%" />'%dict(testsFolder=testsFolder), normalCJK ))
doc = MyDocTemplate(outputfile('test_platypus_paragraphs_autoleading.pdf ')) doc = MyDocTemplate(outputfile('test_platypus_paragraphs_autoleading.pdf '))
doc.build(story) doc.build(story)
DEJAVUSANS = ('DejaVuSans','DejaVuSans-Bold','DejaVuSans-Oblique','DejaVuSans-Bo
ldOblique')
def haveDejaVu():
from reportlab.pdfbase.ttfonts import TTFont
for x in DEJAVUSANS:
try:
TTFont(x,x+'.ttf')
except:
return False
return True
DEJAVUSANS = ('DejaVuSans','DejaVuSans-Bold','DejaVuSans-Oblique','DejaVuSans-Bo
ldOblique')
def alphaSortedItems(d): def alphaSortedItems(d):
return (i[1] for i in sorted((j[0].lower(),j) for j in d.items())) return (i[1] for i in sorted((j[0].lower(),j) for j in d.items()))
def tentities(title, b, fn): def tentities(title, b, fn):
from reportlab.platypus.paraparser import greeks from reportlab.platypus.paraparser import greeks
from reportlab.platypus.doctemplate import SimpleDocTemplate from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.pdfbase.pdfmetrics import stringWidth, registerFont, register FontFamily from reportlab.pdfbase.pdfmetrics import stringWidth, registerFont, register FontFamily
from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase.ttfonts import TTFont
from reportlab.platypus.tables import TableStyle, Table from reportlab.platypus.tables import TableStyle, Table
from reportlab.platypus.paragraph import Paragraph from reportlab.platypus.paragraph import Paragraph
 End of changes. 3 change blocks. 
13 lines changed or deleted 124 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)