本文整理汇总了Python中reportlab.platypus.paragraph.Paragraph类的典型用法代码示例。如果您正苦于以下问题:Python Paragraph类的具体用法?Python Paragraph怎么用?Python Paragraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Paragraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: prepare_first_page
def prepare_first_page(canvas, document):
p1 = Paragraph(presentation.title, styles['Heading'])
p2 = Paragraph(
presentation.owner.get_full_name(), styles['SubHeading'])
avail_width = width - inch
avail_height = height - inch
w1, h1 = p1.wrap(avail_width, avail_height)
w2, h2 = p2.wrap(avail_width, avail_height)
f = Frame(
inch / 2,
inch / 2,
width - inch,
height - inch,
leftPadding=0,
bottomPadding=0,
rightPadding=0,
topPadding=0
)
f.addFromList([p1, p2], canvas)
document.pageTemplate.frames[0].height -= h1 + h2 + inch / 2
document.pageTemplate.frames[1].height -= h1 + h2 + inch / 2
canvas.saveState()
canvas.setStrokeColorRGB(0, 0, 0)
canvas.line(
width / 2, inch / 2, width / 2, height - inch - h1 - h2)
canvas.restoreState()
开发者ID:hanleybrand,项目名称:rooibos,代码行数:28,代码来源:viewers.py
示例2: beforeDrawPage
def beforeDrawPage(self, canvas, doc):
canvas.setFont(serif_font, 8)
canvas.saveState()
if pdfstyles.show_title_page_footer:
canvas.line(footer_margin_hor, footer_margin_vert, page_width - footer_margin_hor, footer_margin_vert)
footertext = [_(titlepagefooter)]
if pdfstyles.show_creation_date:
locale.setlocale(locale.LC_ALL, "")
footertext.append(
pdfstyles.creation_date_txt % time.strftime(pdfstyles.creation_date_format, time.localtime())
)
lines = [formatter.cleanText(line, escape=False) for line in footertext]
txt = "<br/>".join(line if isinstance(line, unicode) else unicode(line, "utf-8") for line in lines)
p = Paragraph(txt, text_style(mode="footer"))
w, h = p.wrap(print_width, print_height)
canvas.translate((page_width - w) / 2.0, footer_margin_vert - h - 0.25 * cm)
p.canv = canvas
p.draw()
canvas.restoreState()
if self.cover:
width, height = self._scale_img(pdfstyles.title_page_image_size, self.cover)
if pdfstyles.title_page_image_pos[0] is None:
x = (page_width - width) / 2.0
else:
x = max(0, min(page_width - width, pdfstyles.title_page_image_pos[0]))
if pdfstyles.title_page_image_pos[1] is None:
y = (page_height - height) / 2.0
else:
y = max(0, min(page_height - height, pdfstyles.title_page_image_pos[1]))
canvas.drawImage(self.cover, x, y, width, height)
开发者ID:tosher,项目名称:mwlib.rl,代码行数:30,代码来源:pagetemplates.py
示例3: beforeDrawPage
def beforeDrawPage(self,canvas,doc):
canvas.setFont(serif_font,8)
canvas.saveState()
if pdfstyles.show_title_page_footer:
canvas.line(footer_margin_hor, footer_margin_vert, page_width - footer_margin_hor, footer_margin_vert )
footertext = [_(titlepagefooter)]
if pdfstyles.show_creation_date:
footertext.append('PDF generated at: %s' % strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()))
p = Paragraph('<br/>'.join([formatter.cleanText(line, escape=False) for line in footertext]),
text_style(mode='footer'))
w,h = p.wrap(print_width, print_height)
canvas.translate( (page_width-w)/2.0, footer_margin_vert - h - 0.25*cm)
p.canv = canvas
p.draw()
canvas.restoreState()
if self.cover:
width, height = self._scale_img(pdfstyles.title_page_image_size, self.cover)
if pdfstyles.title_page_image_pos[0] == None:
x = (page_width - width) / 2.0
else:
x = max(0, min(page_width-width, pdfstyles.title_page_image_pos[0]))
if pdfstyles.title_page_image_pos[1] == None:
y = (page_height - height) / 2.0
else:
y = max(0, min(page_height-height, pdfstyles.title_page_image_pos[1]))
canvas.drawImage(self.cover, x, y, width , height)
开发者ID:EtherGraf,项目名称:mwlib.rl,代码行数:26,代码来源:pagetemplates.py
示例4: ReferenceText
class ReferenceText(IndexingFlowable):
"""Fakery to illustrate how a reference would work if we could
put it in a paragraph."""
def __init__(self, textPattern, targetKey):
self.textPattern = textPattern
self.target = targetKey
self.paraStyle = ParagraphStyle('tmp')
self._lastPageNum = None
self._pageNum = -999
self._para = None
def beforeBuild(self):
self._lastPageNum = self._pageNum
def notify(self, kind, stuff):
if kind == 'Target':
(key, pageNum) = stuff
if key == self.target:
self._pageNum = pageNum
def wrap(self, availWidth, availHeight):
text = self.textPattern % self._lastPageNum
self._para = Paragraph(text, self.paraStyle)
return self._para.wrap(availWidth, availHeight)
def drawOn(self, canvas, x, y, _sW=0):
self._para.drawOn(canvas, x, y, _sW)
开发者ID:Metras,项目名称:loghound,代码行数:27,代码来源:tableofcontents.py
示例5: Figure
class Figure(Flowable):
def __init__(self, imgFile, captionTxt, captionStyle, imgWidth=None, imgHeight=None, margin=(0, 0, 0, 0),
padding=(0, 0, 0, 0), align=None, borderColor=(0.75, 0.75, 0.75), no_mask=False, url=None):
imgFile = imgFile
self.imgPath = imgFile
# workaround for http://code.pediapress.com/wiki/ticket/324
# see http://two.pairlist.net/pipermail/reportlab-users/2008-October/007526.html
if no_mask:
self.i = Image(imgFile, width=imgWidth, height=imgHeight, mask=None)
else:
self.i = Image(imgFile, width=imgWidth, height=imgHeight)
self.imgWidth = imgWidth
self.imgHeight = imgHeight
self.c = Paragraph(captionTxt, style=captionStyle)
self.margin = margin # 4-tuple. margins in order: top, right, bottom, left
self.padding = padding # same as above
self.borderColor = borderColor
self.align = align
self.cs = captionStyle
self.captionTxt = captionTxt
self.availWidth = None
self.availHeight = None
self.url = url
def draw(self):
canv = self.canv
if self.align == "center":
canv.translate((self.availWidth - self.width) / 2, 0)
canv.saveState()
canv.setStrokeColor(Color(self.borderColor[0], self.borderColor[1], self.borderColor[2]))
canv.rect(self.margin[3], self.margin[2], self.boxWidth, self.boxHeight)
canv.restoreState()
canv.translate(self.margin[3] + self.padding[3], self.margin[2] + self.padding[2] - 2)
self.c.canv = canv
self.c.draw()
canv.translate((self.boxWidth - self.padding[1] - self.padding[3] - self.i.drawWidth) / 2, self.captionHeight + 2)
self.i.canv = canv
self.i.draw()
if self.url:
frags = urlparse.urlsplit(self.url.encode('utf-8'))
clean_url = urlparse.urlunsplit((frags.scheme,
frags.netloc,
urllib.quote(frags.path, safe='/'),
urllib.quote(frags.query, safe='=&'),
frags.fragment,)).decode('utf-8')
canv.linkURL(clean_url, (0, 0, self.imgWidth, self.imgHeight), relative=1, thickness=0)
def wrap(self, availWidth, availHeight):
self.availWidth = availWidth
self.availHeight = availHeight
contentWidth = max(self.i.drawWidth, self.c.wrap(self.i.drawWidth, availHeight)[0])
self.boxWidth = contentWidth + self.padding[1] + self.padding[3]
(self.captionWidth, self.captionHeight) = self.c.wrap(contentWidth, availHeight)
self.captionHeight += self.cs.spaceBefore + self.cs.spaceAfter
self.boxHeight = self.i.drawHeight + self.captionHeight + self.padding[0] + self.padding[2]
self.width = self.boxWidth + self.margin[1] + self.margin[3]
self.height = self.boxHeight + self.margin[0] + self.margin[2]
return (self.width, self.height)
开发者ID:tosher,项目名称:mwlib.rl,代码行数:60,代码来源:customflowables.py
示例6: test3
def test3(self):
from reportlab.pdfgen.canvas import Canvas
aW=307
styleSheet = getSampleStyleSheet()
bt = styleSheet['BodyText']
btj = ParagraphStyle('bodyText1j',parent=bt,alignment=TA_JUSTIFY)
p=Paragraph("""<a name='top'/>Subsequent pages test pageBreakBefore, frameBreakBefore and
keepTogether attributes. Generated at 1111. The number in brackets
at the end of each paragraph is its position in the story. llllllllllllllllllllllllll
bbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccc ddddddddddddddddddddd eeeeyyy""",btj)
w,h=p.wrap(aW,1000)
canv=Canvas('test_platypus_paragraph_just.pdf',pagesize=(aW,h))
i=len(canv._code)
p.drawOn(canv,0,0)
ParaCode=canv._code[i:]
canv.saveState()
canv.setLineWidth(0)
canv.setStrokeColorRGB(1,0,0)
canv.rect(0,0,aW,h)
canv.restoreState()
canv.showPage()
canv.save()
from reportlab import rl_config
x = rl_config.paraFontSizeHeightOffset and '50' or '53.17'
good = ['q', '1 0 0 1 0 0 cm', 'q', 'BT 1 0 0 1 0 '+x+' Tm 3.59 Tw 12 TL /F1 10 Tf 0 0 0 rg (Subsequent pages test pageBreakBefore, frameBreakBefore and) Tj T* 0 Tw .23 Tw (keepTogether attributes. Generated at 1111. The number in brackets) Tj T* 0 Tw .299167 Tw (at the end of each paragraph is its position in the story. llllllllllllllllllllllllll) Tj T* 0 Tw 66.9 Tw (bbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccc) Tj T* 0 Tw (ddddddddddddddddddddd eeeeyyy) Tj T* ET', 'Q', 'Q']
ok= ParaCode==good
assert ok, "\nParaCode=%r\nexpected=%r" % (ParaCode,good)
开发者ID:FatihZor,项目名称:infernal-twin,代码行数:29,代码来源:test_platypus_breaking.py
示例7: do_heading
def do_heading(self, text, sty):
# create bookmarkname
bn = sha1(text.encode('utf-8') + sty.name.encode('utf-8')).hexdigest()
# modify paragraph text to include an anchor point with name bn
h = Paragraph(text + '<a name="%s"/>' % bn, sty)
# store the bookmark name on the flowable so afterFlowable can see this
h._bookmarkName = bn
self.story.append(h)
开发者ID:iranzo,项目名称:sarstats,代码行数:8,代码来源:sar_stats.py
示例8: go
def go():
styles = getSampleStyleSheet()
style=styles['Normal']
p1 = Paragraph('This is a paragraph', style )
print(p1.wrap(500,701))
print(p1._cache['avail'])
print(len(p1.split(500,701)))
print(p1.wrap(500,700))
print(len(p1.split(500,700)))
开发者ID:aquavitae,项目名称:rst2pdf-py3-dev,代码行数:10,代码来源:test_180.py
示例9: _do_heading
def _do_heading(self, text, sty):
if isinstance(text, list):
text = "_".join(text)
# create bookmarkname
bn = sha1(text + sty.name).hexdigest()
# modify paragraph text to include an anchor point with name bn
h = Paragraph(text + '<a name="%s"/>' % bn, sty)
# store the bookmark name on the flowable so afterFlowable can see this
h._bookmarkName = bn
self.story.append(h)
开发者ID:mbaldessari,项目名称:pcpstats,代码行数:10,代码来源:pcp2pdf_stats.py
示例10: __list_format
def __list_format(canvas, doc):
canvas.saveState()
building_style = ParagraphStyle(name='building_title',
fontSize=__FONT_SIZE__)
t = u'%s<br/>Data afișării: %s<br/>Luna: %s' % (doc.habitam_building.name,
doc.habitam_display,
doc.habitam_month)
p = Paragraph(t, building_style)
p.wrapOn(canvas, 5 * cm, 2 * cm)
p.drawOn(canvas, .5 * cm, __HEIGHT__ - 1.7 * cm)
habitam_brand(canvas, __WIDTH__, __HEIGHT__)
canvas.restoreState()
开发者ID:habitam,项目名称:habitam-core,代码行数:12,代码来源:display_list.py
示例11: _draw_tyvek
def _draw_tyvek(p, inventory):
p.line(15, 245, 345, 245)
p.line(15, 188, 345, 188)
p.line(15, 115, 345, 115)
p.setFontSize(12)
p.drawString(26, 290, 'DC-%0.3d' % inventory.dropship.id)
p.drawString(295, 290, str(inventory.item.id))
if len(inventory.item.name) > 55:
p.setFont('Helvetica-Bold', 8)
else:
p.setFont('Helvetica-Bold', 10)
p.drawString(26, 260, ellipsize(inventory.item.name, 75))
p.setFont('Helvetica-Bold', 10)
p.drawString( 26, 224, 'Console:')
p.drawString(120, 224, inventory.item.category.name)
p.drawString( 26, 200, 'Rating:')
p.drawString(120, 200, inventory.item.rating.title)
p.drawImage(inventory.item.rating.image.path, 211, 197, width=20, height=30)
p.setFont('Helvetica', 10)
styles = getSampleStyleSheet()
para = Paragraph(ellipsize(inventory.item.description, 305), styles['Normal'])
para.wrap(290, 10000)
i = 0
ll = para.breakLines(290)
for l in ll.lines:
if ll.kind == 0:
p.drawString(25, 170 - i, ' '.join(l[1]))
else:
p.drawString(25, 170 - i, ' '.join([x.text for x in l.words]))
i += 10
from code128 import Code128
bar = Code128()
image = bar.getImage(inventory.barcode, 50, "png")
_fd, n = tempfile.mkstemp()
image.save(n, "PNG")
p.drawImage(n, 196, 60, width=140, height=50)
p.setFont('Helvetica-Bold', 10)
p.drawString(236, 50, inventory.barcode)
p.drawImage(
os.path.join(settings.STATIC_ROOT, "img/bw-logo.png"),
26, 80, width=87, height=22)
p.setFont('Helvetica-Bold', 10)
p.drawString(25, 70, 'PO Box 6487')
p.drawString(25, 58, 'Delray Beach, FL 33482-9901')
p.showPage()
开发者ID:chrisblythe812,项目名称:gamemine,代码行数:53,代码来源:views.py
示例12: test2
def test2(self):
'''CJK splitting in multi-frag case'''
style = ParagraphStyle('test', wordWrap = 'CJK')
p = Paragraph('bla <i>blub</i> '*130 , style)
aW,aH=439.275590551,121.88976378
w,h=p.wrap(aW,aH)
S=p.split(aW,aH)
assert len(S)==2, 'Multi frag CJK splitting failed'
w0,h0=S[0].wrap(aW,aH)
assert h0<=aH,'Multi-frag CJK split[0] has wrong height %s >= available %s' % (H0,aH)
w1,h1=S[1].wrap(aW,aH)
assert h0+h1==h, 'Multi-frag-CJK split[0].height(%s)+split[1].height(%s) don\'t add to original %s' % (h0,h1,h)
开发者ID:Jbaumotte,项目名称:web2py,代码行数:12,代码来源:test_platypus_paragraphs.py
示例13: wrap
def wrap(self, availWidth, availHeight):
# reduce the available width & height by the padding so the wrapping
# will use the correct size
style = self.style
availWidth -= style.paddingLeft + style.paddingRight
availHeight -= style.paddingTop + style.paddingBottom
# call the base class to do wrapping and calculate the size
Paragraph.wrap(self, availWidth, availHeight)
# increase the calculated size by the padding
self.width += style.paddingLeft + style.paddingRight
self.height += style.paddingTop + style.paddingBottom
return (self.width, self.height)
开发者ID:bogdanf,项目名称:cardsbyme,代码行数:15,代码来源:pisa_reportlab.py
示例14: test2
def test2(self):
"""CJK splitting in multi-frag case"""
style = ParagraphStyle("test", wordWrap="CJK")
p = Paragraph("bla <i>blub</i> " * 130, style)
aW, aH = 439.275590551, 121.88976378
w, h = p.wrap(aW, aH)
S = p.split(aW, aH)
assert len(S) == 2, "Multi frag CJK splitting failed"
w0, h0 = S[0].wrap(aW, aH)
assert h0 <= aH, "Multi-frag CJK split[0] has wrong height %s >= available %s" % (H0, aH)
w1, h1 = S[1].wrap(aW, aH)
assert h0 + h1 == h, "Multi-frag-CJK split[0].height(%s)+split[1].height(%s) don't add to original %s" % (
h0,
h1,
h,
)
开发者ID:TribunoDev,项目名称:pm,代码行数:16,代码来源:test_platypus_paragraphs.py
示例15: prepare_first_page
def prepare_first_page(canvas, document):
p1 = Paragraph(presentation.title, styles['Heading'])
p2 = Paragraph(presentation.owner.get_full_name(), styles['SubHeading'])
avail_width = width - inch
# TODO: determine if the complaint about height being undeclared is just pycharm or if its a problem
# if it is possibly a problem "it's better to be explicit" so refactor
avail_height = height - inch
w1, h1 = p1.wrap(avail_width, avail_height)
w2, h2 = p2.wrap(avail_width, avail_height)
f = Frame(inch / 2, inch / 2, width - inch, height - inch,
leftPadding=0, bottomPadding=0, rightPadding=0, topPadding=0)
f.addFromList([p1, p2], canvas)
document.pageTemplate.frames[0].height -= h1 + h2 + inch / 2
document.pageTemplate.frames[1].height -= h1 + h2 + inch / 2
canvas.saveState()
canvas.setStrokeColorRGB(0, 0, 0)
canvas.line(width / 2, inch / 2, width / 2, height - inch - h1 - h2)
canvas.restoreState()
开发者ID:eResearchSandpit,项目名称:rooibos,代码行数:20,代码来源:viewers.py
示例16: test2
def test2(self):
sty = ParagraphStyle(name = 'normal')
sty.fontName = 'Times-Roman'
sty.fontSize = 10
sty.leading = 12
p = Paragraph('one two three',sty)
p.wrap(20,36)
self.assertEqual(len(p.split(20,24)),2) #widows allowed
self.assertEqual(len(p.split(20,16)),0) #orphans disallowed
p.allowWidows = 0
self.assertEqual(len(p.split(20,24)),0) #widows disallowed
p.allowOrphans = 1
self.assertEqual(len(p.split(20,16)),2) #orphans allowed
开发者ID:FatihZor,项目名称:infernal-twin,代码行数:14,代码来源:test_platypus_breaking.py
示例17: beforeDrawPage
def beforeDrawPage(self,canvas,doc):
canvas.setFont(serif_font,8)
canvas.saveState()
if pdfstyles.show_title_page_footer:
canvas.line(footer_margin_hor, footer_margin_vert, page_width - footer_margin_hor, footer_margin_vert )
footertext = [_(titlepagefooter)]
if pdfstyles.show_creation_date:
footertext.append('PDF generated at: %s' % strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()))
p = Paragraph('<br/>'.join([formatter.cleanText(line, escape=False) for line in footertext]),
text_style(mode='footer'))
w,h = p.wrap(print_width, print_height)
canvas.translate( (page_width-w)/2.0, 0.2*cm)
p.canv = canvas
p.draw()
canvas.restoreState()
if self.cover:
width = 12 * cm
img = Image.open(self.cover)
w,h = img.size
height = width/w*h
x = (page_width - width) / 2.0
y = (page_height - height) / 2.0
canvas.drawImage(self.cover, x, y, width , height)
开发者ID:ingob,项目名称:mwlib.rl,代码行数:23,代码来源:pagetemplates.py
示例18: __init__
def __init__(self,imgFile, captionTxt, captionStyle, imgWidth=None, imgHeight=None, margin=(0,0,0,0), padding=(0,0,0,0), align=None, borderColor=(0.75,0.75,0.75), no_mask=False, url=None):
imgFile = imgFile
self.imgPath = imgFile
# workaround for http://code.pediapress.com/wiki/ticket/324
# see http://two.pairlist.net/pipermail/reportlab-users/2008-October/007526.html
if no_mask:
self.i = Image(imgFile, width=imgWidth, height=imgHeight, mask=None)
else:
self.i = Image(imgFile, width=imgWidth, height=imgHeight)
self.imgWidth = imgWidth
self.imgHeight = imgHeight
self.c = Paragraph(captionTxt, style=captionStyle)
self.margin = margin # 4-tuple. margins in order: top, right, bottom, left
self.padding = padding # same as above
self.borderColor = borderColor
self.align = align
self.cs = captionStyle
self.captionTxt = captionTxt
self.availWidth = None
self.availHeight = None
self.url = url
开发者ID:ingob,项目名称:mwlib.rl,代码行数:21,代码来源:customflowables.py
示例19: test0
def test0(self):
"A basic document drawing some strings"
c = Canvas(outputfile('test_multibyte_jpn.pdf'))
c.setFont('Helvetica', 30)
c.drawString(100,700, 'Japanese Font Support')
c.setStrokeColor(colors.red)
#unicode font automatically supplies the encoding
pdfmetrics.registerFont(UnicodeCIDFont('HeiseiMin-W3'))
msg = u'\u6771\u4EAC : Unicode font, unicode input'
self.hDraw(c, msg, 'HeiseiMin-W3', 100, 600)
msg = u'\u6771\u4EAC : Unicode font, utf8 input'.encode('utf8')
self.hDraw(c, msg, 'HeiseiMin-W3', 100, 575)
# now try verticals - this is broken, not sure how to make it
# work in post Unicode world.
pdfmetrics.registerFont(CIDFont('HeiseiMin-W3','90ms-RKSJ-V'))
c.setFont('HeiseiMin-W3-90ms-RKSJ-V', 16)
c.drawString(450, 650, '\223\214\213\236 vertical Shift-JIS')
height = c.stringWidth('\223\214\213\236 vertical Shift-JIS', 'HeiseiMin-W3-90ms-RKSJ-V', 16)
c.rect(450-8,650,16,-height)
pdfmetrics.registerFont(CIDFont('HeiseiMin-W3','EUC-V'))
c.setFont('HeiseiMin-W3-EUC-V', 16)
c.drawString(475, 650, '\xC5\xEC\xB5\xFE vertical EUC')
height = c.stringWidth('\xC5\xEC\xB5\xFE vertical EUC', 'HeiseiMin-W3-EUC-V', 16)
c.rect(475-8,650,16,-height)
from reportlab.platypus.paragraph import Paragraph
from reportlab.lib.styles import ParagraphStyle
jStyle = ParagraphStyle('jtext',
fontName='HeiseiMin-W3',
fontSize=12,
wordWrap="CJK"
)
gatwickText = '\xe3\x82\xac\xe3\x83\x88\xe3\x82\xa6\xe3\x82\xa3\xe3\x83\x83\xe3\x82\xaf\xe7\xa9\xba\xe6\xb8\xaf\xe3\x81\xa8\xe9\x80\xa3\xe7\xb5\xa1\xe9\x80\x9a\xe8\xb7\xaf\xe3\x81\xa7\xe7\x9b\xb4\xe7\xb5\x90\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x82\x8b\xe5\x94\xaf\xe4\xb8\x80\xe3\x81\xae\xe3\x83\x9b\xe3\x83\x86\xe3\x83\xab\xe3\x81\xa7\xe3\x81\x82\xe3\x82\x8b\xe5\xbd\x93\xe3\x83\x9b\xe3\x83\x86\xe3\x83\xab\xe3\x81\xaf\xe3\x80\x81\xe8\xa1\x97\xe3\x81\xae\xe4\xb8\xad\xe5\xbf\x83\xe9\x83\xa8\xe3\x81\x8b\xe3\x82\x8930\xe5\x88\x86\xe3\x81\xae\xe5\xa0\xb4\xe6\x89\x80\xe3\x81\xab\xe3\x81\x94\xe3\x81\x96\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe5\x85\xa8\xe5\xae\xa2\xe5\xae\xa4\xe3\x81\xab\xe9\xab\x98\xe9\x80\x9f\xe3\x82\xa4\xe3\x83\xb3\xe3\x82\xbf\xe3\x83\xbc\xe3\x83\x8d\xe3\x83\x83\xe3\x83\x88\xe7\x92\xb0\xe5\xa2\x83\xe3\x82\x92\xe5\xae\x8c\xe5\x82\x99\xe3\x81\x97\xe3\x81\xa6\xe3\x81\x8a\xe3\x82\x8a\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe3\x83\x95\xe3\x82\xa1\xe3\x83\x9f\xe3\x83\xaa\xe3\x83\xbc\xe3\x83\xab\xe3\x83\xbc\xe3\x83\xa0\xe3\x81\xaf5\xe5\x90\x8d\xe6\xa7\x98\xe3\x81\xbe\xe3\x81\xa7\xe3\x81\x8a\xe6\xb3\x8a\xe3\x82\x8a\xe3\x81\x84\xe3\x81\x9f\xe3\x81\xa0\xe3\x81\x91\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe3\x81\xbe\xe3\x81\x9f\xe3\x80\x81\xe3\x82\xa8\xe3\x82\xb0\xe3\x82\xbc\xe3\x82\xaf\xe3\x83\x86\xe3\x82\xa3\xe3\x83\x96\xe3\x83\xab\xe3\x83\xbc\xe3\x83\xa0\xe3\x81\xae\xe3\x81\x8a\xe5\xae\xa2\xe6\xa7\x98\xe3\x81\xaf\xe3\x80\x81\xe3\x82\xa8\xe3\x82\xb0\xe3\x82\xbc\xe3\x82\xaf\xe3\x83\x86\xe3\x82\xa3\xe3\x83\x96\xe3\x83\xa9\xe3\x82\xa6\xe3\x83\xb3\xe3\x82\xb8\xe3\x82\x92\xe3\x81\x94\xe5\x88\xa9\xe7\x94\xa8\xe3\x81\x84\xe3\x81\x9f\xe3\x81\xa0\xe3\x81\x91\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe4\xba\x8b\xe5\x89\x8d\xe3\x81\xab\xe3\x81\x94\xe4\xba\x88\xe7\xb4\x84\xe3\x81\x84\xe3\x81\x9f\xe3\x81\xa0\xe3\x81\x91\xe3\x82\x8b\xe3\x82\xbf\xe3\x82\xa4\xe3\x83\xa0\xe3\x83\x88\xe3\x82\xa5\xe3\x83\x95\xe3\x83\xa9\xe3\x82\xa4\xe3\x83\xbb\xe3\x83\x91\xe3\x83\x83\xe3\x82\xb1\xe3\x83\xbc\xe3\x82\xb8\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x81\xe7\xa9\xba\xe6\xb8\xaf\xe3\x81\xae\xe9\xa7\x90\xe8\xbb\x8a\xe6\x96\x99\xe9\x87\x91\xe3\x81\x8c\xe5\x90\xab\xe3\x81\xbe\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x8a\xe3\x82\x8a\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82'
gatwickText2= '\xe3\x82\xac\xe3\x83\x88\xe3\x82\xa6\xe3\x82\xa3\xe3\x83\x83\xe3\x82\xaf<font color=red>\xe7\xa9\xba\xe6\xb8\xaf\xe3\x81\xa8\xe9\x80\xa3\xe7\xb5\xa1\xe9\x80\x9a\xe8\xb7\xaf\xe3\x81\xa7\xe7\x9b\xb4\xe7\xb5\x90</font>\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x82\x8b\xe5\x94\xaf\xe4\xb8\x80\xe3\x81\xae\xe3\x83\x9b\xe3\x83\x86\xe3\x83\xab\xe3\x81\xa7\xe3\x81\x82\xe3\x82\x8b\xe5\xbd\x93\xe3\x83\x9b\xe3\x83\x86\xe3\x83\xab\xe3\x81\xaf\xe3\x80\x81\xe8\xa1\x97\xe3\x81\xae\xe4\xb8\xad\xe5\xbf\x83\xe9\x83\xa8\xe3\x81\x8b\xe3\x82\x8930\xe5\x88\x86\xe3\x81\xae\xe5\xa0\xb4\xe6\x89\x80\xe3\x81\xab\xe3\x81\x94\xe3\x81\x96\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe5\x85\xa8\xe5\xae\xa2\xe5\xae\xa4\xe3\x81\xab\xe9\xab\x98\xe9\x80\x9f\xe3\x82\xa4\xe3\x83\xb3\xe3\x82\xbf\xe3\x83\xbc\xe3\x83\x8d\xe3\x83\x83\xe3\x83\x88<link fg="blue" href="http://www.reportlab.com">\xe7\x92\xb0\xe5\xa2\x83\xe3\x82\x92\xe5\xae\x8c\xe5\x82\x99</link>\xe3\x81\x97\xe3\x81\xa6<u>\xe3\x81\x8a\xe3\x82\x8a\xe3\x81\xbe\xe3\x81\x99</u>\xe3\x80\x82\xe3\x83\x95\xe3\x82\xa1\xe3\x83\x9f\xe3\x83\xaa\xe3\x83\xbc\xe3\x83\xab\xe3\x83\xbc\xe3\x83\xa0\xe3\x81\xaf5\xe5\x90\x8d\xe6\xa7\x98\xe3\x81\xbe\xe3\x81\xa7\xe3\x81\x8a\xe6\xb3\x8a\xe3\x82\x8a\xe3\x81\x84\xe3\x81\x9f\xe3\x81\xa0\xe3\x81\x91\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe3\x81\xbe\xe3\x81\x9f\xe3\x80\x81\xe3\x82\xa8\xe3\x82\xb0\xe3\x82\xbc\xe3\x82\xaf\xe3\x83\x86\xe3\x82\xa3\xe3\x83\x96\xe3\x83\xab\xe3\x83\xbc\xe3\x83\xa0\xe3\x81\xae\xe3\x81\x8a\xe5\xae\xa2\xe6\xa7\x98\xe3\x81\xaf\xe3\x80\x81\xe3\x82\xa8\xe3\x82\xb0\xe3\x82\xbc\xe3\x82\xaf\xe3\x83\x86\xe3\x82\xa3\xe3\x83\x96\xe3\x83\xa9\xe3\x82\xa6\xe3\x83\xb3\xe3\x82\xb8\xe3\x82\x92\xe3\x81\x94\xe5\x88\xa9\xe7\x94\xa8\xe3\x81\x84\xe3\x81\x9f\xe3\x81\xa0\xe3\x81\x91\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\xe4\xba\x8b\xe5\x89\x8d\xe3\x81\xab\xe3\x81\x94\xe4\xba\x88\xe7\xb4\x84\xe3\x81\x84\xe3\x81\x9f\xe3\x81\xa0\xe3\x81\x91\xe3\x82\x8b\xe3\x82\xbf\xe3\x82\xa4\xe3\x83\xa0\xe3\x83\x88\xe3\x82\xa5\xe3\x83\x95\xe3\x83\xa9\xe3\x82\xa4\xe3\x83\xbb\xe3\x83\x91\xe3\x83\x83\xe3\x82\xb1\xe3\x83\xbc\xe3\x82\xb8\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x81\xe7\xa9\xba\xe6\xb8\xaf\xe3\x81\xae\xe9\xa7\x90\xe8\xbb\x8a\xe6\x96\x99\xe9\x87\x91\xe3\x81\x8c\xe5\x90\xab\xe3\x81\xbe\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x8a\xe3\x82\x8a\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82'
c.setFont('HeiseiMin-W3', 12)
jPara = Paragraph(gatwickText, jStyle)
jPara.wrap(300, 200)
jPara.drawOn(c, 100, 220)
jPara = Paragraph(gatwickText2, jStyle)
jPara.wrap(300, 200)
jPara.drawOn(c, 100, 320)
c.setFillColor(colors.purple)
tx = c.beginText(100, 200)
tx.setFont('Helvetica', 12)
tx.textLines("""This document shows sample output in Japanese
from the Reportlab PDF library. This page shows the two fonts
available and tests our ability to measure the width of glyphs
in both horizontal and vertical writing, with proportional and
fixed-width characters. The red boxes should be the same width
(or height) as the character strings they surround.
The next pages show more samples and information.
""")
c.drawText(tx)
c.setFont('Helvetica',10)
c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
c.showPage()
c.setFont('Helvetica', 30)
c.drawString(100,700, 'Japanese TrueType Font Support')
msg = u'\u6771\u4EAC : Unicode font'.encode('utf8')
msg2 = u'utf8 input 0123456789 ABCDEF'.encode('utf8')
from reportlab.pdfbase.ttfonts import TTFont
try:
msmincho = TTFont('MS Mincho','msmincho.ttc',subfontIndex=0,asciiReadable=0)
fn = ' file=msmincho.ttc subfont 0'
except:
try:
msmincho = TTFont('MS Mincho','msmincho.ttf',asciiReadable=0)
fn = 'file=msmincho.ttf'
except:
#Ubuntu - works on Lucid Lynx if xpdf-japanese installed
try:
msmincho = TTFont('MS Mincho','ttf-japanese-mincho.ttf')
fn = 'file=msmincho.ttf'
except:
msmincho = None
if msmincho is None:
c.setFont('Helvetica', 12)
c.drawString(100,600, 'Cannot find msmincho.ttf or msmincho.ttc')
else:
#.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:reportlab,代码行数:101,代码来源:test_multibyte_jpn.py
示例20: draw
def draw(self):
self.canv.saveState()
self.canv.translate(0,0)
self.canv.rotate(self.angle)
Paragraph.draw(self)
self.canv.restoreState()
开发者ID:barney-s,项目名称:pypdfocr,代码行数:6,代码来源:pypdfocr_pdf.py
注:本文中的reportlab.platypus.paragraph.Paragraph类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论