本文整理汇总了Python中reportlab.lib.enums.TA_RIGHT属性的典型用法代码示例。如果您正苦于以下问题:Python enums.TA_RIGHT属性的具体用法?Python enums.TA_RIGHT怎么用?Python enums.TA_RIGHT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类reportlab.lib.enums
的用法示例。
在下文中一共展示了enums.TA_RIGHT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def __init__(self):
super(TopoPagina, self).__init__()
self.elements = []
txt = SystemField(expression='%(report_title)s', top=0.65 *
cm, left=0 * cm, width=19.4 * cm, height=0.8 * cm)
txt.style = {'fontName': REPORT_FONT_BOLD,
'fontSize': 15, 'alignment': TA_CENTER, 'leading': 15}
self.elements.append(txt)
txt = SystemField(expression='Página %(page_number)s de %(last_page_number)s',
top=3.1 * cm, left=0 * cm, width=19.4 * cm, height=0.5 * cm)
txt.style = {'fontName': REPORT_FONT, 'fontSize': 8.5,
'alignment': TA_RIGHT, 'leading': 8.5}
self.elements.append(txt)
self.elements.append(Line(top=3.6 * cm, bottom=3.6 *
cm, left=0 * cm, right=19.4 * cm, stroke_width=0.3))
self.height = 3.65 * cm
示例2: wrap
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def wrap(self, availWidth, availHeight):
# try to get the caption aligned
if self.caption:
self._getCaptionPara()
w, h = self.captionPara.wrap(self.width, availHeight - self.figureHeight)
self.captionHeight = h + self.captionGap
self.height = self.captionHeight + self.figureHeight
if w>self.width: self.width = w
else:
self.height = self.figureHeight
if self.hAlign in ('CENTER','CENTRE',TA_CENTER):
self.dx = 0.5 * (availWidth - self.width)
elif self.hAlign in ('RIGHT',TA_RIGHT):
self.dx = availWidth - self.width
else:
self.dx = 0
return (self.width, self.height)
示例3: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def __init__(self):
super(InfoTotais.band_header, self).__init__()
self.elements = []
self.elements.append(Line(top=0.1*cm, bottom=0.1*cm, left=0*cm, right=7.6*cm, stroke_width=0.3, dash=(1,1)))
txt = self.inclui_texto_sem_borda(nome='', texto='Qtde. Total de Itens', top=0.1*cm, left=0*cm, width=3.8*cm)
txt.style = {'fontName': FONTE_NFCE, 'fontSize': FONTE_TAMANHO_7, 'leading': FONTE_TAMANHO_7}
txt = self.inclui_campo_sem_borda(nome=u'qtd_itens', conteudo=u'NFe.quantidade_itens', top=0.1*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}
txt = self.inclui_texto_sem_borda(nome='', texto='Valor Total R$', top=0.6*cm, left=0*cm, width=3.8*cm)
txt.style = {'fontName': FONTE_NFCE, 'fontSize': FONTE_TAMANHO_7, 'leading': FONTE_TAMANHO_7}
txt = self.inclui_campo_sem_borda(nome=u'valor_total', conteudo=u'NFe.valor_total_nota', top=0.6*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 = 1.1*cm
示例4: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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()
示例5: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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()
示例6: _header_footer
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def _header_footer(self, canvas, doc):
# Save the state of our canvas so we can draw on it
canvas.saveState()
style_right = ParagraphStyle(name='right', parent=self.bodystyle, fontName='arialuni',
fontSize=10, alignment=TA_RIGHT)
fieldsight_logo = Image('http://' + self.base_url +'/static/images/fs1.jpg')
fieldsight_logo._restrictSize(1.5 * inch, 1.5 * inch)
# headerleft = Paragraph("FieldSight", self.bodystyle)
headerright = Paragraph(self.project_name, style_right)
# w1, h1 = headerleft.wrap(doc.width, doc.topMargin)
w2, h2 = headerright.wrap(doc.width, doc.topMargin)
textWidth = stringWidth(self.project_name, fontName='arialuni',
fontSize=10)
fieldsight_logo.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin + 12)
headerright.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin + 20)
try:
project_logo = Image(self.project_logo)
project_logo._restrictSize(0.4 * inch, 0.4 * inch)
project_logo.drawOn(canvas, headerright.width + doc.leftMargin -0.5 * inch - textWidth, doc.height + doc.topMargin + 10)
except:
pass
# header.drawOn(canvas, doc.leftMargin + doc.width, doc.height + doc.topMargin +20)
# Footer
footer = Paragraph('Page no. '+str(canvas._pageNumber), style_right)
w, h = footer.wrap(doc.width, doc.bottomMargin)
footer.drawOn(canvas, doc.leftMargin, h + 40)
# Release the canvas
canvas.restoreState()
示例7: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def __init__(self, invoice_path, pdf_info=None, precision='0.01'):
if not pdf_info:
pdf_info = self.default_pdf_info
SimpleDocTemplate.__init__(
self,
invoice_path,
pagesize=letter,
rightMargin=inch,
leftMargin=inch,
topMargin=inch,
bottomMargin=inch,
**pdf_info.__dict__
)
self.precision = precision
self._defined_styles = getSampleStyleSheet()
self._defined_styles.add(
ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
)
self._defined_styles.add(
ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
)
self.invoice_info = None
self.service_provider_info = None
self.client_info = None
self.is_paid = False
self._items = []
self._item_tax_rate = None
self._transactions = []
self._story = []
self._bottom_tip = None
self._bottom_tip_align = None
示例8: _hAlignAdjust
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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
示例9: readAlignment
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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
示例10: _getCaptionPara
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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))
示例11: __init__
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def __init__(self, invoice_path, pdf_info=None, precision='0.01'):
if not pdf_info:
pdf_info = self.default_pdf_info
SimpleDocTemplate.__init__(
self,
invoice_path,
pagesize=letter,
rightMargin=inch,
leftMargin=inch,
topMargin=inch,
bottomMargin=inch,
**pdf_info.__dict__
)
self.precision = precision
self._defined_styles = getSampleStyleSheet()
self._defined_styles.add(
ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
)
self._defined_styles.add(
ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
)
self.invoice_info = None
self.service_provider_info = None
self.client_info = None
self.is_paid = False
self._items = []
self._item_discount_rate = None
self._transactions = []
self._story = []
self._bottom_tip = None
self._bottom_tip_align = None
self._amount_recieved = None
示例12: _hAlignAdjust
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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
示例13: drawOn
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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()
示例14: add_banner
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [as 别名]
def add_banner(self, canvas, doc):
height_adjust = 1
if self.tlp_color:
if self.tlp_color == 'WHITE':
text_color = white
elif self.tlp_color == 'RED':
text_color = red
elif self.tlp_color == 'AMBER':
text_color = orange
else:
text_color = lawngreen
self.tlp_color = 'GREEN'
if 'banner_style' not in self.style:
self.style.add(ParagraphStyle(name='banner_style',
textColor=text_color,
textTransform='uppercase',
alignment=TA_RIGHT))
banner = Paragraph(
self.span_text(self.bold_text('TLP:' + self.tlp_color), bgcolor='black'),
self.style['banner_style'])
w, h = banner.wrap(doc.width, doc.topMargin)
banner.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin + (h + 12 * mm))
w, h = banner.wrap(doc.width, doc.bottomMargin)
banner.drawOn(canvas, doc.leftMargin, h + 12 * mm)
height_adjust = 3
return height_adjust
示例15: draw
# 需要导入模块: from reportlab.lib import enums [as 别名]
# 或者: from reportlab.lib.enums import TA_RIGHT [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)