Python-reportlab教程

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

k'PythonReportlab§lReportlabÆS©Á2010c107FContents1ReportlabSSSCCC12{{{üüü˜˜˜‡‡‡~~~fff23˜˜˜CanvasŒŒŒ24kkk'''platypus˜˜˜ŸŸŸ35PythonreportlabLLL‚‚‚|||„„„66Pythonreportlab-ãããLLL87(((åå劊Š11Á‡µ3python­.p§˜„‹ÑÑ¿ØU÷v^rI¦§reportlab´pythonþéИ‡m`DPDFLa¥§©þk'Treportlab˜‡ÆS]§øˆ ÆSëœ1ReportlabSSSCCCÄuPython²`DPDFLa¥Reportlab§ØáuPythonIOa¥§¤±7LÃÄe1a¥¿SCϏ9rã¡=†PDF§¤±„I‡Pythonimaginglibrary(PIL)a¥ü‡a¥e1/ŒµReportLab::k|±Python2.X‡§O3.x‡é¯˜ÑSC{µwindows^rŒ±†e1.exeSC§†SCXJ´linux^r§Œ±e1èSC(ïÆkSCPIL)SC{(I‡rSC“è˜3pythonSC8¹Ü· ˜)µ1$pythonsetup.pyinstallSCƒŒ±$1g‘~f§Ï~˜3Lib/site-packages/reportlab/test8¹e§\Œ±ÏL±e-$1¤k~fµ$cd/usr/local/Python.2.4.3/Lib/site-packages/reportlab/test$pythonrunAll.py..............................................................................................................-------------------------------------------------------Ran143testsin45.886sOKLogsandoutputfileswrittentofolder.../ReportLab_tmp/reportlab_testÙ¢\XJ´windows^r…Ø'%ù~f§Œ±aL§I‡3pythonshellÑ\importreportlab.pdfgenŒÿÁ´ÄSC(SCÒØ[`2{{{üüü˜˜˜‡‡‡~~~fffe¡5ww1˜‡~f§‹ÆÙ¦˜§k5ww{üHelloWorld§S3Reportlab¥$?|‡Ò´3pdfgen¥canvas閧…3ù‡p#N^r¦^©§ã¡Mïg½ÂPDF©‡L5w“èµ1µCreatedonAug23,2010@author:leyond.info2µfromreportlab.pdfgenimportcanvas3µc=canvas.Canvas(hello.pdf)4µc.drawString(100,750,HelloWorld!)5µc.showPage()6:c.save()é{ü§¦^ReportLab5)¤PDF\Œ±@Ò–´3x㘧Ïd1˜1lpdf-gen¥\canvas§Om©±xÄk¦^Canvasé–)¤˜‡¶hello.pdf©‡§,¦^drawString{3canvas¥100@100?±xÑ.HelloWorld!.iùpI‡5¿‹I ˜§Ï~·‚:‹I3†þ§reportlabŽ˜%´3†e§ù˜:؇· showPage()^u)©§du¡vkSN§vkåJ§d3ù‡~f¥§Œ±íØù1“聘1“èòƒc±x¤kSN\©‡§ÄKò)˜xSN$1“èƒò3éA8¹e)¤hello.pdf©‡§„þ¡ýAã g-13˜˜˜CanvasŒŒŒe5wwXÛ˜reportlab¥canvasŒCanvas%@ŒA4,XJ-þ‡‹SN&µŒ§@kTXÛ˜QºÄkI‡\letter¬µ1:fromreportlab.lib.pagesizesimportletter,3MïCanvas閴½pagesize:1:canvas=canvas.Canvas('myfile.pdf',pagesize=letter)·‚„Œ±wwCanvas(Ù¦á5˜µ21:Pythonreportlab-helloworlddef__init__(self,filename,pagesize=letter,bottomup=1,pageCompression=0,encoding=rl_config.defaultEncoding,verbosity=0encrypt=None):õ]ÕëReportlabUserGuidee5·‚wwXÛ|^pagesize˜Canvas&µŒ~fµ5ww“èµ1:fromreportlab.lib.pagesizesimportletter2:fromreportlab.pdfgenimportcanvas3:canvas=canvas.Canvas(form.pdf,pagesize=letter)4:canvas.setLineWidth(.3)5:canvas.setFont('Helvetica',12)6:canvas.drawString(30,750,'OFFICIALCOMMUNIQUE')7:canvas.drawString(30,735,'OFACMEINDUSTRIES')8:canvas.drawString(500,750,12/12/2010)9:canvas.line(480,747,580,747)10:canvas.drawString(275,725,'AMOUNTOWED:')11:canvas.drawString(500,725,$1,000.00)12:canvas.line(378,723,580,723)13:canvas.drawString(30,703,'RECEIVEDBY:')14:canvas.line(120,700,580,700)15:canvas.drawString(120,703,JOHNDOE)16:canvas.save()ù‡´‡{üâü~f§†ƒcHelloworld~fØӃ?3ucanvas.line(),\Œ±ÏL½éX,Y53canvasþx‚XJŒ±§„Œ±^§5±›L‚§w,ù'„¡Ù¦¼ê'XsetLineWidth(.3),ù‡-^uwŠreportlab±õo)5±›‚ã„k\Œ±ÏLsetFont¼ê5½iNڌ32:pdf-partial-form- g2$1“èƒò3éA8¹e)¤my le.pdf©‡§„þ¡ýAã g-24kkk'''platypus˜˜˜ŸŸŸwwE,platypus,platypus¡Pagelayoutandtopologyusingscript,´˜«pÙÛa¥§B^rŒ±ÏL§S{üME,©Platypus´˜|Ø%±x§Sa§JøŽŒ˜!©ÙÛ!L‚!a.±9©õUÏL˜‡{ü~fäN`²§Xeã§ù´˜‡Êv±ÏüµùX{´˜‡~f§Ïü´ØŒUkpythonlogo35w“èµ1:importtime2:fromreportlab.lib.enumsimportTA_JUSTIFY3:fromreportlab.lib.pagesizesimportletter4:fromreportlab.platypusimportSimpleDocTemplate,Paragraph,Spacer,Image5:fromreportlab.lib.stylesimportgetSampleStyleSheet,ParagraphStyle6:fromreportlab.lib.unitsimportinch7:doc=SimpleDocTemplate(form_letter.pdf,pagesize=letter,8:rightMargin=72,leftMargin=72,9:topMargin=72,10:bottomMargin=18)11:Story=[]12:logo=python_logo.png13:magName=Pythonista14:issueNum=1215:subPrice=99.0016:limitedDate=03/05/201017:freeGift=tinfoilhat18:formatted_time=time.ctime()19:full_name=MikeDriscoll20:address_parts=[411StateSt.,Marshalltown,IA50158]21:im=Image(logo,2*inch,2*inch)22:Story.append(im)23:styles=getSampleStyleSheet()424:styles.add(ParagraphStyle(name='Justify',alignment=TA_JUSTIFY))25:ptext='fontsize=12%s/font'%formatted_time26:Story.append(Paragraph(ptext,styles[Normal]))27:Story.append(Spacer(1,12))28:#Createreturnaddress29:ptext='fontsize=12%s/font'%full_name30:Story.append(Paragraph(ptext,styles[Normal]))31:forpartinaddress_parts:32:ptext='fontsize=12%s/font'%part.strip()33:Story.append(Paragraph(ptext,styles[Normal]))34:Story.append(Spacer(1,12))35:ptext='fontsize=12Dear%s:/font'%full_name.split()[0].strip()36:Story.append(Paragraph(ptext,styles[Normal]))37:Story.append(Spacer(1,12))38:ptext='fontsize=12Wewouldliketowelcomeyoutoour39:subscriberbasefor%sMagazine!\40:Youwillreceive%sissuesatthe41:excellentintroductorypriceof$%s.42:Pleaserespondby\%stostartreceiving43:yoursubscriptionandgetthefollowing44:freegift:%s./font'45:%(magName,46:issueNum,47:subPrice,48:limitedDate,49:freeGift)50:Story.append(Paragraph(ptext,styles[Justify]))51:Story.append(Spacer(1,12))

1 / 11
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功