本文整理汇总了Python中reportlab.lib.enums.TA_LEFT属性的典型用法代码示例。如果您正苦于以下问题:Python enums.TA_LEFT属性的具体用法?Python enums.TA_LEFT怎么用?Python enums.TA_LEFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类reportlab.lib.enums
的用法示例。
在下文中一共展示了enums.TA_LEFT属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def __init__(self):
super(BandaFoot, self).__init__()
self.ender_info = False
self.elements = []
self.elements.append(Line(top=1.5 * cm, bottom=1.5 *
cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3))
txt = Label(text='Gerado por djangoSIGE', top=1.5 * cm,
left=0 * cm, width=19.4 * cm, height=0.5 * cm)
txt.style = {'fontName': REPORT_FONT_BOLD,
'fontSize': 8, 'alignment': TA_LEFT, 'leading': 8}
self.elements.append(txt)
txt = SystemField(expression='Data da impressão: %(now:%d/%m/%Y)s',
top=1.5 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm)
txt.style = {'fontName': REPORT_FONT, 'fontSize': 8,
'alignment': TA_RIGHT, 'leading': 8}
self.elements.append(txt)
self.height = 2 * cm
示例2: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def __init__(self, program = None):
from reportlab.lib.colors import black
if program is None:
program = []
self.lineOpHandlers = [] # for handling underlining and hyperlinking, etc
self.program = program
self.indent = self.rightIndent = 0.0
self.baseindent = 0.0 # adjust this to add more indentation for bullets, eg
self.fontName = "Helvetica"
self.fontSize = 10
self.leading = 12
self.fontColor = black
self.x = self.y = self.rise = 0.0
from reportlab.lib.enums import TA_LEFT
self.alignment = TA_LEFT
self.textStateStack = []
示例3: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def drawOn(self, canv, x, y, _sW=0):
if _sW > 0 and hasattr(self, 'hAlign'):
a = self.hAlign
if a in ('CENTER', 'CENTRE', TA_CENTER):
x += 0.5 * _sW
elif a in ('RIGHT', TA_RIGHT):
x += _sW
elif a not in ('LEFT', TA_LEFT):
raise ValueError("Bad hAlign value " + str(a))
xobj = self.xobj
xobj_name = makerl(canv._doc, xobj)
xscale = self.drawWidth / self._imgw
yscale = self.drawHeight / self._imgh
canv.saveState()
canv.translate(x, y)
canv.scale(xscale, yscale)
canv.doForm(xobj_name)
canv.restoreState()
示例4: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def drawOn(self, canv, x, y, _sW=0, width=0, height=0):
if _sW > 0 and hasattr(self, 'hAlign'):
a = self.hAlign
if a in ('CENTER', 'CENTRE', TA_CENTER):
x += 0.5 * _sW
elif a in ('RIGHT', TA_RIGHT):
x += _sW
elif a not in ('LEFT', TA_LEFT):
raise ValueError("Bad hAlign value " + str(a))
xobj = self.xobj
xobj_name = makerl(canv._doc, xobj)
xscale = (width or self.drawWidth) / xobj.w
yscale = (height or self.drawHeight) / xobj.h
x -= xobj.x * xscale
y -= xobj.y * yscale
canv.saveState()
canv.translate(x, y)
canv.scale(xscale, yscale)
canv.doForm(xobj_name)
canv.restoreState()
示例5: _hAlignAdjust
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def _hAlignAdjust(self,x,sW=0):
if sW and hasattr(self,'hAlign'):
a = self.hAlign
if a in ('CENTER','CENTRE', TA_CENTER):
x += 0.5*sW
elif a in ('RIGHT',TA_RIGHT):
x += sW
elif a not in ('LEFT',TA_LEFT):
raise ValueError("Bad hAlign value "+str(a))
return x
示例6: readAlignment
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def readAlignment(text):
up = text.upper()
if up == 'LEFT':
return TA_LEFT
elif up == 'RIGHT':
return TA_RIGHT
elif up in ['CENTER', 'CENTRE']:
return TA_CENTER
elif up == 'JUSTIFY':
return TA_JUSTIFY
示例7: _getCaptionPara
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def _getCaptionPara(self):
caption = self.caption
captionFont = self.captionFont
captionSize = self.captionSize
captionTextColor = self.captionTextColor
captionBackColor = self.captionBackColor
captionAlign = self.captionAlign
captionPosition = self.captionPosition
if self._captionData!=(caption,captionFont,captionSize,captionTextColor,captionBackColor,captionAlign,captionPosition):
self._captionData = (caption,captionFont,captionSize,captionTextColor,captionBackColor,captionAlign,captionPosition)
if isinstance(caption,Paragraph):
self.captionPara = caption
elif isinstance(caption,strTypes):
self.captionStyle = ParagraphStyle(
'Caption',
fontName=captionFont,
fontSize=captionSize,
leading=1.2*captionSize,
textColor = captionTextColor,
backColor = captionBackColor,
#seems to be getting ignored
spaceBefore=self.captionGap,
alignment=TA_LEFT if captionAlign=='left' else TA_RIGHT if captionAlign=='right' else TA_CENTER,
)
#must build paragraph now to get sequencing in synch with rest of story
self.captionPara = Paragraph(self.caption, self.captionStyle)
else:
raise ValueError('Figure caption of type %r is not a string or Paragraph' % type(caption))
示例8: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def __init__(self):
super(InfoPagamento.band_detail, self).__init__()
self.elements = []
txt = self.inclui_campo_sem_borda(nome=u'forma_pagamento', conteudo=u'forma_pagamento_danfe', top=0*cm, left=0*cm, width=3.8*cm)
txt.style = {'fontName': FONTE_NFCE, 'fontSize': FONTE_TAMANHO_7, 'leading': FONTE_TAMANHO_7, 'alignment': TA_LEFT}
txt = self.inclui_campo_sem_borda(nome=u'valor_pagamento', conteudo=u'valor_pagamento_danfe', top=0*cm, left=3.8*cm, width=3.8*cm)
txt.style = {'fontName': FONTE_NFCE, 'fontSize': FONTE_TAMANHO_7, 'leading': FONTE_TAMANHO_7, 'alignment': TA_RIGHT}
#self.auto_expand_height = True
self.height = 0.5*cm
示例9: _hAlignAdjust
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def _hAlignAdjust(self,x,sW=0):
if sW and hasattr(self,'hAlign'):
a = self.hAlign
if a in ('CENTER','CENTRE', TA_CENTER):
x += 0.5*sW
elif a in ('RIGHT',TA_RIGHT):
x += sW
elif a not in ('LEFT',TA_LEFT):
raise ValueError, "Bad hAlign value "+str(a)
return x
示例10: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def drawOn(self, canv, x, y, _sW=0):
if _sW and hasattr(self, 'hAlign'):
a = self.hAlign
if a in ('CENTER', 'CENTRE', TA_CENTER):
x += 0.5 * _sW
elif a in ('RIGHT', TA_RIGHT):
x += _sW
elif a not in ('LEFT', TA_LEFT):
raise ValueError("Bad hAlign value " + str(a))
canv.saveState()
canv.translate(x, y)
canv.scale(self.drawWidth / self._w, self.drawHeight / self._h)
self.doc._drawOn(canv)
canv.restoreState()
示例11: draw
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def draw(self):
style = self.style
lines = self.lines
rightIndent = style.rightIndent
leftIndent = style.leftIndent
leading = style.leading
font = style.fontName
size = style.fontSize
alignment = style.alignment
firstindent = style.firstLineIndent
c = self.canv
escape = c._escape
#if debug:
# print "FAST", id(self), "page number", c.getPageNumber()
height = self.height
#if debug:
# c.rect(0,0,-1, height-size, fill=1, stroke=1)
c.translate(0, height-size)
textobject = c.beginText()
code = textobject._code
#textobject.setTextOrigin(0,firstindent)
textobject.setFont(font, size)
if style.textColor:
textobject.setFillColor(style.textColor)
first = 1
y = 0
basicWidth = self.availableWidth - rightIndent
count = 0
nlines = len(lines)
while count<nlines:
(text, length, nwords) = lines[count]
count = count+1
thisindent = leftIndent
if first:
thisindent = firstindent
if alignment==TA_LEFT:
x = thisindent
elif alignment==TA_CENTER:
extra = basicWidth - length
x = thisindent + extra/2.0
elif alignment==TA_RIGHT:
extra = basicWidth - length
x = thisindent + extra
elif alignment==TA_JUSTIFY:
x = thisindent
if count<nlines and nwords>1:
# patch from doug@pennatus.com, 9 Nov 2002, no extraspace on last line
textobject.setWordSpace((basicWidth-length)/(nwords-1.0))
else:
textobject.setWordSpace(0.0)
textobject.setTextOrigin(x,y)
textobject.textOut(text)
y = y-leading
c.drawText(textobject)
示例12: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_LEFT [as 别名]
def drawOn(self, canv, x, y, _sW=0):
if _sW and hasattr(self, 'hAlign'):
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
a = self.hAlign
if a in ('CENTER', 'CENTRE', TA_CENTER):
x = x + 0.5 * _sW
elif a in ('RIGHT', TA_RIGHT):
x = x + _sW
elif a not in ('LEFT', TA_LEFT):
raise ValueError("Bad hAlign value " + str(a))
height = 0
if HAS_MATPLOTLIB:
global fonts
canv.saveState()
canv.translate(x, y)
try:
(
width,
height,
descent,
glyphs,
rects,
used_characters,
) = self.parser.parse(
enclose(self.s), 72, prop=FontProperties(size=self.fontsize)
)
for ox, oy, fontname, fontsize, num, symbol_name in glyphs:
if not fontname in fonts:
fonts[fontname] = fontname
pdfmetrics.registerFont(TTFont(fontname, fontname))
canv.setFont(fontname, fontsize)
col_conv = ColorConverter()
rgb_color = col_conv.to_rgb(self.color)
canv.setFillColorRGB(rgb_color[0], rgb_color[1], rgb_color[2])
canv.drawString(ox, oy, chr(num))
canv.setLineWidth(0)
canv.setDash([])
for ox, oy, width, height in rects:
canv.rect(ox, oy + 2 * height, width, height, fill=1)
except:
# FIXME: report error
col_conv = ColorConverter()
rgb_color = col_conv.to_rgb(self.color)
canv.setFillColorRGB(rgb_color[0], rgb_color[1], rgb_color[2])
canv.drawString(0, 0, self.s)
canv.restoreState()
else:
canv.saveState()
canv.drawString(x, y, self.s)
canv.restoreState()
if self.label:
log.info('Drawing equation-%s' % self.label)
canv.bookmarkHorizontal('equation-%s' % self.label, 0, height)