本文整理汇总了Python中reportlab.platypus.flowables.Image类的典型用法代码示例。如果您正苦于以下问题:Python Image类的具体用法?Python Image怎么用?Python Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: draw
def draw(self):
canvas = self.canv
img = Image(self.barcode)
width, height = img.wrapOn(canvas, 0, 0)
width = width * 72. / 300
height = height * 72. / 300
canvas.drawImage(
self.barcode,
self.x * mm,
(self.y * mm * -1) - height,
width,
height,
)
开发者ID:IMIO,项目名称:imio.helpers,代码行数:13,代码来源:pdf.py
示例3: _pageheader
def _pageheader(self):
if self.preview:
t = self.canvas.beginText()
t.setTextOrigin(6*cm, 4*cm)
t.setFont("Times-Italic", 70)
t.setFillColorRGB(0.9,0.9,0.9)
t.textLines("PREVIEW PREVIEW")
self.canvas.rotate(45)
self.canvas.drawText(t)
self.canvas.rotate(-45)
im = Image("%s/PostgreSQL_logo.1color_blue.300x300.png" % self.imagedir, width=3*cm, height=3*cm)
im.drawOn(self.canvas, 2*cm, 25*cm)
t = self.canvas.beginText()
t.setFillColorRGB(0,0,0,0)
t.setFont("Times-Roman", 10)
t.setTextOrigin(6*cm, 27.5*cm)
t.textLines("""PostgreSQL Europe
Carpeaux Diem
13, rue du Square Carpeaux
75018 PARIS
France
""")
self.canvas.drawText(t)
t = self.canvas.beginText()
t.setTextOrigin(2*cm, 23*cm)
t.setFont("Times-Roman", 10)
t.textLine("")
t.textLines("""
Your contact: Guillaume Lelarge
Function: PostgreSQL Europe Treasurer
E-mail: [email protected]
""")
self.canvas.drawText(t)
t = self.canvas.beginText()
t.setTextOrigin(11*cm, 23*cm)
t.setFont("Times-Italic", 11)
t.textLine("To:")
t.setFont("Times-Roman", 11)
t.textLines(self.recipient)
self.canvas.drawText(t)
p = self.canvas.beginPath()
p.moveTo(2*cm, 18.9*cm)
p.lineTo(19*cm, 18.9*cm)
self.canvas.drawPath(p)
开发者ID:louiseGrandjonc,项目名称:pgeu-website,代码行数:48,代码来源:pgeuinvoice.py
示例4: _draw_image
def _draw_image(self, img_path, width=None, height=None, **kwargs):
"""Draw an image"""
canvas = self.canv
img = Image(img_path)
_width, _height = img.wrapOn(canvas, 0, 0)
_width = _width * 72. / 300
_height = _height * 72. / 300
if width is not None:
_width = width
if height is not None:
_height = height
canvas.drawImage(
img_path,
self.cursor.x * self.unit,
self.cursor.y * self.unit - _height,
_width,
_height,
)
开发者ID:affinitic,项目名称:affinitic.pdf,代码行数:18,代码来源:flowable.py
示例5: __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
示例6: wrap
def wrap(self, availWidth, availHeight):
#print 123, self.drawWidth, self.drawHeight, self.pisaZoom
#self.drawWidth *= self.pisaZoom
#self.drawHeight *= self.pisaZoom
# print 456, self.drawWidth, self.drawHeight
width = min(self.drawWidth, availWidth)
# print 999, width, self.drawWidth, availWidth
factor = float(width) / self.drawWidth
# print 123, factor
self.drawHeight = self.drawHeight * factor
self.drawWidth = width
return Image.wrap(self, availWidth, availHeight)
开发者ID:bogdanf,项目名称:cardsbyme,代码行数:12,代码来源:pisa_reportlab.py
示例7: __init__
def __init__( self, attrs ):
# PIL is required to draw images
try:
import PIL
except ImportError:
Error("""
PIL (Python Imaging Library) is required to use images in
your documents.
You should download and install it.
http://www.pythonware.com/products/pil/
""")
Properties.__init__(self)
self.graphic( attrs )
if self.properties['src']:
self.filename = self.properties['src']
else:
Error('No source defined for external-graphic element.')
Image.__init__( self, self.filename )
开发者ID:BackupTheBerlios,项目名称:pixies-svn,代码行数:22,代码来源:graphic.py
示例8: add_image
def add_image(self, src, width, height, align=CENTER, caption=None):
if src.split(".")[-1] in ["png", "PNG"]:
try:
f = open(src, 'rb')
data = StringIO(f.read())
except:
return
else:
img = Image(data, width, height)
f.close()
else:
img = Image(src, width, height)
img.hAlign = align
if caption:
caption_p = Paragraph(caption, self.theme.paragraph_centered)
image_table = Table([[img], [caption_p]], width)
image_table.setStyle(TableStyle([('ALIGN',(-1,-1),(-1,-1),
'CENTER')]))
self.add(image_table)
else:
self.add(img)
开发者ID:remiolsen,项目名称:NouGAT,代码行数:23,代码来源:__init__.py
示例9: fill_sender
def fill_sender(self):
"""Fills sender identity"""
from reportlab.platypus.flowables import Image
from core.pdf.utils import Paragraph
# Sender identity
sender_paragraphs = []
if self.invoice_base.current_revision.sender:
sender_paragraphs.append(Paragraph(self.invoice_base.current_revision.sender, self.style['Small']))
sender_paragraphs.append(Paragraph(self.invoice_base.tenant.name, self.style['Small']))
if self.invoice_base.current_revision.sender_address:
sender_paragraphs.append(Paragraph(u'\n'.join(self.invoice_base.current_revision.sender_address.get_formatted()), self.style['Small']))
# Add layout table if logo or paragraphs
if self.invoice_base.tenant.logo_cache:
logo = Image(self.invoice_base.tenant.logo_cache)
logo_width, logo_height = logo._restrictSize(50*mm, 20*mm)
self.table(
[[logo, sender_paragraphs]],
(logo_width + 4*mm, None),
self.style['LayoutTable'],
rowHeights=(20*mm,)
)
else:
for paragraph in sender_paragraphs:
self.append(paragraph)
开发者ID:FacturaVirtual,项目名称:vosae-app,代码行数:24,代码来源:invoice_base.py
示例10: __init__
def __init__(self, title, enterprise, interval, logo):
self.title = title
self.enterprise = enterprise
self.interval = interval
self.logo = logo
self.width, self.height = A4
self.buf = StringIO()
self.canvas = Canvas(self.buf, pagesize=A4)
self.page_title = ''
self.page_rows = []
self.page_frags = 0
self.page_num = 1
# Build story.
self.canvas.saveState()
self.canvas.setStrokeColor(colors.RED)
self.canvas.setLineWidth(2)
self.canvas.roundRect(self.margin, self.edenwall_height + self.margin, self.width, self.height, 20, stroke=1, fill=0)
self.canvas.setFillColor(colors.GREEN2)
self.canvas.setStrokeColor(colors.GREEN1)
self.canvas.roundRect(- self.margin, - self.margin, self.width - self.margin, self.edenwall_height + self.margin,
20, stroke=1, fill=1)
# TODO do not hardcode this values.
img = Image('/var/lib/ufwi_rpcd/edenwall.png', 1209 / (300/(self.edenwall_height-self.margin/2)), self.edenwall_height-self.margin/2)
img.drawOn(self.canvas, self.margin, self.margin/4)
self.canvas.restoreState()
if self.logo:
img = Image(StringIO(self.logo))
img._setup_inner()
img.drawOn(self.canvas, (self.width - self.margin)/2 - img.drawWidth/2, 2*self.height/3)
offset = 40
self.canvas.setFillColor(black)
self.canvas.setFont("Helvetica-Bold", self.big_title_height)
self.canvas.drawCentredString((self.width-self.margin)/2, self.height/3, title)
self.canvas.setFont("Helvetica-Bold", self.frag_title_height)
self.canvas.drawString(offset, self.height - offset, enterprise)
开发者ID:maximerobin,项目名称:Ufwi,代码行数:42,代码来源:report.py
示例11: image
def image(self, name, width, height, halign='CENTER'):
im = Image(name, width=width, height=height)
im.hAlign = halign
self._store_flowable(im)
开发者ID:sourabhgupta90,项目名称:testing_frame,代码行数:4,代码来源:django_report_lab.py
示例12: Dessine_texte
def Dessine_texte(self, texte="", nom_categorie=None, y=0, hauteur=0):
""" Dessine le texte de la case """
if texte == None :
texte = ""
# Dessine le nom de la catégorie
if nom_categorie != None :
self.canvas.saveState()
self.canvas.setStrokeColor(ColorWxToPdf(self.parent.dictDonnees["case_titre_texte_couleur"], alpha=1))
self.canvas.setFillColor(ColorWxToPdf(self.parent.dictDonnees["case_titre_texte_couleur"], alpha=1))
self.canvas.setLineWidth(0.5)
self.canvas.setDash(0.5, 4)
self.canvas.line(0, self.hauteur_case - y +1, self.largeur_case, self.hauteur_case - y +1)
self.canvas.setFont(self.parent.dictDonnees["case_titre_nom_police"], size=self.parent.dictDonnees["case_titre_taille_police"]-2)
self.canvas.drawString(4, self.hauteur_case - y - 10, nom_categorie)
self.canvas.restoreState()
# Propriétés
self.canvas.setFillColor(ColorWxToPdf(self.parent.dictDonnees["case_texte_couleur"], alpha=1))
# Création des paragraphes
taille_police = self.parent.dictDonnees["case_taille_police"]
espace_vertical = self.parent.dictDonnees["case_espace_vertical"]
liste_paragraphes, hauteur_paragraphes = self.GetParagraphes(texte, taille_police)
ratio_depassement = (hauteur_paragraphes + (len(liste_paragraphes) - 1) * espace_vertical) / hauteur
# Vérifie si le texte ne dépasse pas de la case
if ratio_depassement > 1 :
taille_police = taille_police / ratio_depassement
liste_paragraphes, hauteur_paragraphes = self.GetParagraphes(texte, taille_police)
# Calcule l'espace vertical et la marge supérieure
if self.parent.dictDonnees["case_repartition_verticale"] == True :
# marge_haut = self.parent.dictDonnees["case_marge_haut"]
# espace_vertical = (hauteur - hauteur_paragraphes - marge_haut * 2) / (len(liste_paragraphes) - 1)
bordure = 4
espace_vertical = (hauteur - hauteur_paragraphes - bordure*2) / (len(liste_paragraphes) - 1 + 2)
marge_haut = espace_vertical + bordure
else :
espace_vertical = self.parent.dictDonnees["case_espace_vertical"]
marge_haut = (hauteur - (hauteur_paragraphes + (len(liste_paragraphes) - 1) * espace_vertical)) / 2.0
# Préparation des images
if self.parent.dictDonnees["case_separateur_type"] == "image" and self.parent.dictDonnees["case_separateur_image"] != "aucune":
img = wx.Image(Chemins.GetStaticPath("Images/Menus/%s" % self.parent.dictDonnees["case_separateur_image"]), wx.BITMAP_TYPE_ANY)
ratio_image = 1.0 * img.GetWidth() / img.GetHeight()
largeur_image = self.largeur_case / 1.5
hauteur_image = largeur_image / ratio_image
separateur_image = Image(Chemins.GetStaticPath("Images/Menus/%s" % self.parent.dictDonnees["case_separateur_image"]), width=largeur_image, height=hauteur_image)
# Dessine les lignes
y_paragraphe = self.hauteur_case - y - marge_haut
index = 0
for hauteur_paragraphe, paragraphe in liste_paragraphes:
y_paragraphe -= hauteur_paragraphe
paragraphe.drawOn(self.canvas, 0, y_paragraphe)
# Dessine l'image de séparation
if self.parent.dictDonnees["case_separateur_type"] != "aucun" and index < len(liste_paragraphes) - 1:
if self.parent.dictDonnees["case_separateur_type"] == "image" :
separateur_image.drawOn(self.canvas, self.largeur_case / 2.0 - separateur_image._width / 2.0, y_paragraphe - espace_vertical / 2.0 - separateur_image._height / 2.0)
elif self.parent.dictDonnees["case_separateur_type"] == "ligne":
largeur_separateur = self.largeur_case / 3.5
x_separateur = (self.largeur_case - largeur_separateur) / 2.0
self.canvas.setStrokeColor(ColorWxToPdf(wx.WHITE, alpha=0.2))
self.canvas.setLineWidth(0.25)
self.canvas.line(x_separateur, y_paragraphe - espace_vertical / 2.0, x_separateur + largeur_separateur, y_paragraphe - espace_vertical / 2.0)
y_paragraphe -= espace_vertical
index += 1
开发者ID:bogucool,项目名称:Noethys,代码行数:72,代码来源:UTILS_Impression_menu.py
示例13: fill
def fill(self):
from django.template.defaultfilters import date as format_date, floatformat
from reportlab.platypus.flowables import Image
from core.pdf.utils import Paragraph
from invoicing import currency_format
# Sender frame
# Sender identity
sender_paragraphs = []
if self.invoice_base.current_revision.sender:
sender_paragraphs.append(Paragraph(self.invoice_base.current_revision.sender, self.style['Small']))
sender_paragraphs.append(Paragraph(self.invoice_base.tenant.name, self.style['Small']))
if self.invoice_base.current_revision.sender_address:
sender_paragraphs.append(Paragraph(u'\n'.join(self.invoice_base.current_revision.sender_address.get_formatted()), self.style['Small']))
# Add layout table if logo or paragraphs
if self.invoice_base.tenant.logo_cache:
logo = Image(self.invoice_base.tenant.logo_cache)
logo_width, logo_height = logo._restrictSize(50 * mm, 20 * mm)
self.table(
[[logo, sender_paragraphs]],
(logo_width + 4 * mm, None),
self.style['LayoutTable'],
rowHeights=(20 * mm,)
)
else:
for paragraph in sender_paragraphs:
self.append(paragraph)
# Billing address frame
self.next_frame()
if self.invoice_base.current_revision.contact:
self.p(self.invoice_base.current_revision.contact.get_full_name(upper_name=True), style=self.style['Address'])
if self.invoice_base.current_revision.organization:
self.p(self.invoice_base.current_revision.organization.corporate_name, style=self.style['Address'])
if self.invoice_base.current_revision.billing_address:
self.p(u'\n'.join(self.invoice_base.current_revision.billing_address.get_formatted()), style=self.style['Address'])
# Delivery address frame
self.next_frame()
if self.invoice_base.current_revision.contact:
self.p(self.invoice_base.current_revision.contact.get_full_name(upper_name=True), style=self.style['Address'])
if self.invoice_base.current_revision.organization:
self.p(self.invoice_base.current_revision.organization.corporate_name, style=self.style['Address'])
if self.invoice_base.current_revision.delivery_address:
self.p(u'\n'.join(self.invoice_base.current_revision.delivery_address.get_formatted()), style=self.style['Address'])
# Rest of the report
self.next_frame()
invoice_reference = pgettext('date', 'Undefined') if getattr(self.invoice_base, 'has_temporary_reference', None) else self.invoice_base.reference
self.table([[
' '.join([unicode(self.invoice_base.RECORD_NAME).upper(), invoice_reference]),
format_date(self.invoice_base.current_revision.invoicing_date, 'DATE_FORMAT')
]], (12 * cm, 5 * cm), style=self.style['InvoiceBaseReferencesTable'])
self.spacer()
rows = [[
pgettext('table-headers', 'Description'),
pgettext('table-headers', 'Qty'),
pgettext('table-headers', 'Unit price (excl. tax)'),
pgettext('table-headers', 'Tax'),
pgettext('table-headers', 'Total (excl. tax)')
]]
for item in self.invoice_base.current_revision.line_items:
rows.append([
item.description,
floatformat(item.quantity, -2),
currency_format(item.unit_price),
'{0:.2%}'.format(item.tax.rate),
currency_format(item.total_price, self.invoice_base.current_revision.currency.symbol)
])
col_widths = (85 * mm, 20 * mm, 20 * mm, 20 * mm, 25 * mm)
self.table(rows, col_widths, repeatRows=1, style=self.style['InvoiceBaseItemsTable'])
self.spacer()
rows = [[
_('TOTAL (excl. tax)'),
currency_format(self.invoice_base.sub_total, self.invoice_base.current_revision.currency.symbol)
]]
for tax in self.invoice_base.taxes_amounts:
rows.append([
'%(tax_name)s (%(tax_rate)s)' % {
'tax_name': tax.get('name'),
'tax_rate': '{0:.2%}'.format(tax.get('rate'))
},
currency_format(tax.get('amount'), self.invoice_base.current_revision.currency.symbol)
])
rows.append([
_('TOTAL (incl. tax)'),
currency_format(self.invoice_base.amount, self.invoice_base.current_revision.currency.symbol)
])
col_widths = (None, 25 * mm)
self.start_keeptogether()
self.table(rows, col_widths, hAlign='RIGHT', style=self.style['InvoiceBaseSummaryTable'])
self.end_keeptogether()
# Legal notices
self.spacer()
self.start_keeptogether()
if self.invoice_base.is_quotation():
self.p(_("Valid until %(quotation_validity)s") % {
#.........这里部分代码省略.........
开发者ID:peicheng,项目名称:vosae-app,代码行数:101,代码来源:default.py
示例14: draw
def draw(self):
self.canv.rotate(90)
Image.draw(self)
开发者ID:swasher,项目名称:pdfupload,代码行数:3,代码来源:reporting_platypus_example.py
示例15: insertImage
def insertImage(self, imagePath, height, width):
img = Image(imagePath)
img.drawHeight = height
img.drawWidth = width
self.Story.append(img)
开发者ID:pombredanne,项目名称:owasp-wte,代码行数:5,代码来源:PDFWriter.py
示例16: add_image
def add_image(self, src, width, height, align=CENTER):
img = Image(src, width, height)
img.hAlign = align
self.add(img)
开发者ID:akurex,项目名称:web2py-csv-process-and-pdf-generator,代码行数:4,代码来源:__init__.py
示例17: createUrgentCoverPage
def createUrgentCoverPage(page_size=PAGE_SIZE_LETTER,
total_pages=1,
recipient_name='',
recipient_phone='',
recipient_fax='',
sender_name='',
sender_phone='',
sender_fax='',
sender_email='',
regarding='',
message='',
preserve_formatting=False,
output=None):
s = getSampleStyleSheet()
story = []
i = Image(os.path.join(prop.image_dir, 'other', 'urgent_title.png'), width=424, height=92)
i.hAlign = 'LEFT'
story.append(i)
story.append(Spacer(1, inch))
story.append(HRFlowable(width='100%', color='black'))
ps = ParagraphStyle(name='normal',
fontName='Times-Roman',
#fontName='STSong-Light',
#fontName='UMing',
fontSize=12)
recipient_name_label = Paragraph("To:", ps)
recipient_name_text = Paragraph(escape(recipient_name[:64]), ps)
recipient_fax_label = Paragraph("Fax:", ps)
recipient_fax_text = Paragraph(escape(recipient_fax[:64]), ps)
recipient_phone_label = Paragraph("Phone:", ps)
recipient_phone_text = Paragraph(escape(recipient_phone[:64]), ps)
sender_name_label = Paragraph("From:", ps)
sender_name_text = Paragraph(escape(sender_name[:64]), ps)
sender_phone_label = Paragraph("Phone:", ps)
sender_phone_text = Paragraph(escape(sender_phone[:64]), ps)
sender_email_label = Paragraph("Email:", ps)
sender_email_text = Paragraph(escape(sender_email[:64]), ps)
regarding_label = Paragraph("Regarding:", ps)
regarding_text = Paragraph(escape(regarding[:128]), ps)
date_time_label = Paragraph("Date:", ps)
date_time_text = Paragraph(strftime("%a, %d %b %Y %H:%M:%S (%Z)", localtime()), ps)
total_pages_label = Paragraph("Total Pages:", ps)
total_pages_text = Paragraph("%d" % total_pages, ps)
data = [[recipient_name_label, recipient_name_text],
[recipient_fax_label, recipient_fax_text],
['', ''],
[sender_name_label, sender_name_text],
[sender_phone_label, sender_phone_text],
[sender_email_label, sender_email_text],
['', ''],
[date_time_label, date_time_text],
[total_pages_label, total_pages_text],
[regarding_label, regarding_text],]
LIST_STYLE = TableStyle([#('LINEABOVE', (0,0), (-1,0), 2, colors.black),
#('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
#('LINEBELOW', (0,-1), (-1,-1), 2, colors.black),
('ALIGN', (1,1), (-1,-1), 'RIGHT'),
('VALIGN', (0, 0), (-1, -1), 'TOP'),
])
story.append(Table(data, style=LIST_STYLE))
story.append(HRFlowable(width='100%', color='black'))
if message:
MSG_STYLE = TableStyle([#('LINEABOVE', (0,0), (-1,0), 2, colors.black),
#('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
#('LINEBELOW', (0,-1), (-1,-1), 2, colors.black),
('ALIGN', (1,1), (-1,-1), 'RIGHT'),
('VALIGN', (0, 0), (-1, -1), 'TOP'),
#('SPAN', (-2, 1), (-1, -1)),
])
#story.append(HRFlowable(width='100%', color='black'))
story.append(Spacer(1, 0.5*inch))
# if preserve_formatting:
# message = '\n'.join(message[:2048].splitlines()[:32])
#
# data = [#[Paragraph("Comments/Notes:", ps), ''],
# [Preformatted(escape(message), ps)],]
# else:
# data = [#[Paragraph("Comments/Notes:", ps), ''],
# [Paragraph(escape(message[:2048]), ps), ''],]
#
# #story.append(HRFlowable(width='100%', color='black'))
#.........这里部分代码省略.........
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:101,代码来源:coverpages.py
示例18: wrap
def wrap(self,availWidth,availHeight):
h, w = Image.wrap(self,availHeight,availWidth)
return w, h
开发者ID:swasher,项目名称:pdfupload,代码行数:3,代码来源:reporting_platypus_example.py
示例19: F116Pdf
class F116Pdf(f116_pdf_old.F116PdfOld):
def __init__(self, data, debug=False):
super(F116Pdf, self).__init__(data, debug)
def create_pdf_file(self, file_name, page_size=landscape(A4)):
super(F116Pdf, self).create_pdf_file(file_name, page_size)
def render_page1_image(self):
A4_Width, A4_Height = A4
self.im = Image(_self_path + '/'+u'side1.jpg',width=A4_Height, height=A4_Width)
self.im.drawOn(self.pdf, self.x(0), self.y(0))
self.pdf.line(A4_Height/2, 10, A4_Height/2, A4_Width-10)
def render_page2_image(self):
#TODO добыть картинку 2 стороны
A4_Width, A4_Height = A4
self.im = Image(_self_path + '/'+u'side2.jpg',width=A4_Height, height=A4_Width)
self.im.drawOn(self.pdf, self.x(0), self.y(0))
self.pdf.line(A4_Height/2, 10, A4_Height/2, A4_Width-10)
def render_page1_oneside_data(self, side_data):
self.pdf.setFont('DejaVuSans', 8)
#money
self.pdf.setFont('DejaVuSans', 12)
self.pdf.drawString(self.x(0.9*cm), self.y(15.85*cm), side_data.sum + u" руб. 00 коп.")
self.pdf.setFont('DejaVuSans', 10)
self.pdf.drawString(self.x(2.20*cm), self.y(3.92*cm), side_data.sum)
#to
self.pdf.setFont('DejaVuSans', 8)
#name
self.drawClippingString2(side_data.to_name, self.x(1.7*cm), self.y(14.4*cm), 47)
#address - if need split
if len(side_data.to_address) >= 50: # 33chars for font size 8
#split to 2 line
self.drawClippingString2(side_data.to_address[:50], self.x(1.79*cm), self.y(13.85*cm), 50)
#if len(side_data.to_address[34:] >= ?)# need 3 line?
self.drawClippingString2(side_data.to_address[50:], self.x(0.9*cm), self.y(13.2*cm), 55)
else:
self.drawClippingString2(side_data.to_address, self.x(1.79*cm), self.y(13.85*cm), 50)
#zip_code
zip_code = self.pdf.beginText()
zip_code.setTextOrigin(self.x(6.86*cm), self.y(12.55*cm))
zip_code.setFont('DejaVuSans', 10)
zip_code.setCharSpace(8)
zip_code.textLine(side_data.to_zip_code)
zip_code.setCharSpace(0)
self.pdf.drawText(zip_code)
#from
#name
self.drawClippingString2(side_data.from_name, self.x(2.0*cm), self.y(11.85*cm), 68)
#address - if need split
if len(side_data.from_address) >= 72: # chars for font size 8
#split to 2 line
self.drawClippingString2(side_data.from_address[:72], self.x(1.8*cm), self.y(11.12*cm), 72)
#if len(side_data.to_address[34:] >= ?)# need 3 line?
self.drawClippingString2(side_data.from_address[72:], self.x(0.9*cm), self.y(10.55*cm), 57)
else:
self.drawClippingString2(side_data.from_address, self.x(1.8*cm), self.y(11.12*cm), 72)
#zip_code
zip_code = self.pdf.beginText()
zip_code.setTextOrigin(self.x(10.45*cm), self.y(10.6*cm))
zip_code.setFont('DejaVuSans', 10)
zip_code.setCharSpace(7.5)
zip_code.textLine(side_data.from_zip_code)
zip_code.setCharSpace(0)
self.pdf.drawText(zip_code)
#to_down
self.pdf.setFont('DejaVuSans', 8)
#name
self.drawClippingString2(side_data.to_name, self.x(1.7*cm), self.y(3.12*cm), 73)
#address - if need split
if len(side_data.to_address) >= 60: # 60chars for font size 8
#split to 2 line
self.drawClippingString2(side_data.to_address[:60], self.x(1.8*cm), self.y(2.35*cm), 70)
#if len(self.lside_data.to_address[34:] >= ?)# need 3 line?
self.drawClippingString2(side_data.to_address[60:], self.x(0.9*cm), self.y(1.55*cm), 57)
else:
self.drawClippingString2(side_data.to_address, self.x(1.8*cm), self.y(2.35*cm), 77)
#zip_code
zip_code = self.pdf.beginText()
zip_code.setTextOrigin(self.x(10.4*cm), self.y(1.6*cm))
zip_code.setFont('DejaVuSans', 10)
zip_code.setCharSpace(8)
zip_code.textLine(side_data.to_zip_code)
zip_code.setCharSpace(0)
self.pdf.drawText(zip_code)
#passport data
self.pdf.setFontSize(8)
self.drawClippingString2(side_data.passport_type , self.x(2.9*cm), self.y(9.18*cm), 8)
self.drawClippingString2(side_data.passport_series , self.x(5.85*cm), self.y(9.18*cm), 4)
self.drawClippingString2(side_data.passport_number , self.x(7.6*cm), self.y(9.18*cm), 6)
#.........这里部分代码省略.........
开发者ID:shantilabs,项目名称:russian-post-receipts,代码行数:101,代码来源:f116_pdf.py
示例20: render_page1_image
def render_page1_image(self):
A4_Width, A4_Height = A4
self.im = Image(_self_path + '/'+u'side1.jpg',width=A4_Height, height=A4_Width)
self.im.drawOn(self.pdf, self.x(0), self.y(0))
self.pdf.line(A4_Height/2, 10, A4_Height/2, A4_Width-10)
开发者ID:shantilabs,项目名称:russian-post-receipts,代码行数:5,代码来源:f116_pdf.py
注:本文中的reportlab.platypus.flowables.Image类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论