本文整理匯總了Python中reportlab.platypus.flowables.Image.drawWidth方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.drawWidth方法的具體用法?Python Image.drawWidth怎麽用?Python Image.drawWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類reportlab.platypus.flowables.Image
的用法示例。
在下文中一共展示了Image.drawWidth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: old_tables_test
# 需要導入模塊: from reportlab.platypus.flowables import Image [as 別名]
# 或者: from reportlab.platypus.flowables.Image import drawWidth [as 別名]
#.........這裏部分代碼省略.........
('BACKGROUND', (0, 0), (0, 1), colors.pink),
('SPAN',(0,0),(0,1)),
('BACKGROUND',(-2,1),(-1,1),colors.palegreen),
('SPAN',(-2,1),(-1,1)),
('BACKGROUND',(-2,3),(-1,3),colors.yellow),
('SPAN',(-2,3),(-1,3)),
('BACKGROUND', (2, 3), (2, 4), colors.orange),
('SPAN',(2,3),(2,4)),
]
t=Table(data,style=sty,repeatRows=2)
lst.append(Paragraph("Illustrating splits with spans and repeatRows: nosplit", styleSheet['BodyText']))
lst.append(t)
lst.append(Spacer(0,6))
if 1:
lst.append(Paragraph("Illustrating splits with spans and repeatRows: split(4in,30)", styleSheet['BodyText']))
for s in t.split(4*inch,30):
lst.append(s)
lst.append(Spacer(0,6))
lst.append(Spacer(0,6))
lst.append(Paragraph("Illustrating splits with spans and repeatRows: split(4in,36)", styleSheet['BodyText']))
for s in t.split(4*inch,36):
lst.append(s)
lst.append(Spacer(0,6))
lst.append(Paragraph("Illustrating splits with spans and repeatRows: split(4in,56)", styleSheet['BodyText']))
lst.append(Spacer(0,6))
for s in t.split(4*inch,56):
lst.append(s)
lst.append(Spacer(0,6))
lst.append(PageBreak())
from reportlab.lib.testutils import testsFolder
I = Image(os.path.join(os.path.dirname(testsFolder),'src','tools','pythonpoint','demos','leftlogo.gif'))
I.drawHeight = 1.25*inch*I.drawHeight / I.drawWidth
I.drawWidth = 1.25*inch
#I.drawWidth = 9.25*inch #uncomment to see better messaging
P = Paragraph("<para align=center spaceb=3>The <b>ReportLab Left <font color=red>Logo</font></b> Image</para>", styleSheet["BodyText"])
B = TableBarChart()
BP = Paragraph("<para align=center spaceb=3>A bar chart in a cell.</para>", styleSheet["BodyText"])
data= [['A', 'B', 'C', Paragraph("<b>A pa<font color=red>r</font>a<i>graph</i></b><super><font color=yellow>1</font></super>",styleSheet["BodyText"]), 'D'],
['00', '01', '02', [I,P], '04'],
['10', '11', '12', [I,P], '14'],
['20', '21', '22', '23', '24'],
['30', '31', '32', '33', '34'],
['40', '41', '42', [B,BP], '44']]
t=Table(data,style=[('GRID',(1,1),(-2,-2),1,colors.green),
('BOX',(0,0),(1,-1),2,colors.red),
('LINEABOVE',(1,2),(-2,2),1,colors.blue),
('LINEBEFORE',(2,1),(2,-2),1,colors.pink),
('BACKGROUND', (0, 0), (0, 1), colors.pink),
('BACKGROUND', (1, 1), (1, 2), colors.lavender),
('BACKGROUND', (2, 2), (2, 3), colors.orange),
('BOX',(0,0),(-1,-1),2,colors.black),
('GRID',(0,0),(-1,-1),0.5,colors.black),
('VALIGN',(3,0),(3,0),'BOTTOM'),
('BACKGROUND',(3,0),(3,0),colors.limegreen),
('BACKGROUND',(3,1),(3,1),colors.khaki),
('ALIGN',(3,1),(3,1),'CENTER'),
('BACKGROUND',(3,2),(3,2),colors.beige),
('ALIGN',(3,2),(3,2),'LEFT'),
])
t._argW[3]=1.5*inch
lst.append(t)
示例2: __init__
# 需要導入模塊: from reportlab.platypus.flowables import Image [as 別名]
# 或者: from reportlab.platypus.flowables.Image import drawWidth [as 別名]
#.........這裏部分代碼省略.........
style = [
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
('FONT', (1, 0), (1, -1), "Helvetica-Bold", dictOptions["taille_texte_labels_totaux"]),
('FONT', (2, 0), (2, -1), "Helvetica-Bold", dictOptions["taille_texte_montants_totaux"]),
('GRID', (2, 0), (2, 0), 0.25, colors.black),
('GRID', (2, 1), (2, 1), 0.25, colors.black),
('GRID', (2, 2), (2, 2), 0.25, colors.black),
('ALIGN', (1, 0), (1, -1), 'RIGHT'),
('ALIGN', (2, 0), (2, -1), 'CENTRE'),
('BACKGROUND', (2, 2), (2, 2), couleurFond),
('SPAN', (0, 0), (0, -1)),
]
if mode == "facture" and len(listeMessages) > 0 :
#style.append( ('BACKGROUND', (0, 0), (0, 0), couleurFondActivite) )
style.append( ('FONT', (0, 0), (0, -1), "Helvetica", 8) )
style.append( ('VALIGN', (0, 0), (0, -1), 'TOP') )
tableau = Table(dataTableau, largeursColonnes, rowHeights=[18, 18, None])
tableau.setStyle(TableStyle(style))
story.append(tableau)
# ------------------------- PRELEVEMENTS --------------------
if dictOptions.has_key("afficher_avis_prelevements") and dictValeur.has_key("prelevement") :
if dictValeur["prelevement"] != None and dictOptions["afficher_avis_prelevements"] == True :
paraStyle = ParagraphStyle(name="intro",
fontName="Helvetica",
fontSize=8,
leading=11,
spaceBefore=2,
spaceafter=2,
alignment=1,
backColor=couleurFondActivite,
)
story.append(Spacer(0,20))
story.append(Paragraph(u"<para align='center'><i>%s</i></para>" % dictValeur["prelevement"], paraStyle))
# Texte conclusion
if dictOptions["texte_conclusion"] != "" :
story.append(Spacer(0,20))
paraStyle = ParagraphStyle(name="conclusion",
fontName="Helvetica",
fontSize=dictOptions["taille_texte_conclusion"],
leading=14,
spaceBefore=0,
spaceafter=0,
leftIndent=5,
rightIndent=5,
alignment=dictOptions["alignement_texte_conclusion"],
backColor=ConvertCouleurWXpourPDF(dictOptions["couleur_fond_conclusion"]),
borderColor=ConvertCouleurWXpourPDF(dictOptions["couleur_bord_conclusion"]),
borderWidth=0.5,
borderPadding=5,
)
texte = dictValeur["texte_conclusion"].replace("\\n", "<br/>")
if dictOptions["style_texte_conclusion"] == 0 : texte = u"<para>%s</para>" % texte
if dictOptions["style_texte_conclusion"] == 1 : texte = u"<para><i>%s</i></para>" % texte
if dictOptions["style_texte_conclusion"] == 2 : texte = u"<para><b>%s</b></para>" % texte
if dictOptions["style_texte_conclusion"] == 3 : texte = u"<para><i><b>%s</b></i></para>" % texte
story.append(Paragraph(texte, paraStyle))
# Image signature
if dictOptions["image_signature"] != "" :
cheminImage = dictOptions["image_signature"]
if os.path.isfile(cheminImage) :
img = Image(cheminImage)
largeur, hauteur = int(img.drawWidth * 1.0 * dictOptions["taille_image_signature"] / 100.0), int(img.drawHeight * 1.0 * dictOptions["taille_image_signature"] / 100.0)
if largeur > CADRE_CONTENU[2] or hauteur > CADRE_CONTENU[3] :
raise Exception(_(u"L'image de signature est trop grande. Veuillez diminuer sa taille avec le parametre Taille."))
img.drawWidth, img.drawHeight = largeur, hauteur
if dictOptions["alignement_image_signature"] == 0 : img.hAlign = "LEFT"
if dictOptions["alignement_image_signature"] == 1 : img.hAlign = "CENTER"
if dictOptions["alignement_image_signature"] == 2 : img.hAlign = "RIGHT"
story.append(Spacer(0,20))
story.append(img)
# Saut de page
story.append(PageBreak())
# Finalisation du PDF
## try :
doc.build(story)
## except Exception, err :
## print "Erreur dans ouverture PDF :", err
## if "Permission denied" in err :
## dlg = wx.MessageDialog(None, _(u"Noethys ne peut pas créer le PDF.\n\nVeuillez vérifier qu'un autre PDF n'est pas déjà ouvert en arrière-plan..."), _(u"Erreur d'édition"), wx.OK | wx.ICON_ERROR)
## dlg.ShowModal()
## dlg.Destroy()
## return
# Ouverture du PDF
if ouverture == True :
FonctionsPerso.LanceFichierExterne(nomDoc)
示例3: insertImage
# 需要導入模塊: from reportlab.platypus.flowables import Image [as 別名]
# 或者: from reportlab.platypus.flowables.Image import drawWidth [as 別名]
def insertImage(self, imagePath, height, width):
img = Image(imagePath)
img.drawHeight = height
img.drawWidth = width
self.Story.append(img)