当前位置: 首页>>代码示例>>Python>>正文


Python renderPDF.drawToFile函数代码示例

本文整理汇总了Python中reportlab.graphics.renderPDF.drawToFile函数的典型用法代码示例。如果您正苦于以下问题:Python drawToFile函数的具体用法?Python drawToFile怎么用?Python drawToFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drawToFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    URL = 'http://www.swpc.noaa.gov/ftpdir/weekly/Predict.txt'
    COMMENT_CHARS = '#:'
    
    drawing = Drawing(400, 200)
    data = []
    
    for line in urlopen(URL).readlines():
        if not line.isspace() and not line[0] in COMMENT_CHARS:
            data.append([float(n) for n in line.split()])
            
    pred = [row[2] for row in data]
    high = [row[3] for row in data]
    low = [row[4] for row in data]
    times = [row[0] + row[1]/12.0 for row in data]
       
    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = [zip(times, pred), zip(times, high), zip(times, low)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green
    
    drawing.add(lp)
    
    drawing.add(String(250, 150, 'Sunspots', fontSize = 14, fillColor = colors.red))
    
    renderPDF.drawToFile(drawing, 'report.pdf', 'Sunspots')
开发者ID:satiago,项目名称:workplace,代码行数:31,代码来源:main.py

示例2: drawline

 def drawline(self,time_axis,para,filename):
     self.lp.data = [zip(time_axis,para)]
     self.drawing.add(self.lp)  
     self.drawing.add(self.title)
     self.drawing.add(self.Xlabel)
     self.drawing.add(self.Ylabel)
     renderPDF.drawToFile(self.drawing,filename,'Sunspots')
开发者ID:dongdaqing,项目名称:FrameworkForAndroidTest,代码行数:7,代码来源:reportlabsetting.py

示例3: main

def main(genes, hmmMatches1, hmmMatches2, hsps, cluster, window):
    drawing = Drawing(window.xsize, window.ysize)
    
    y = 50
    xmap = Mapping(margin,window.xsize-margin,window.start,window.end)
    addAxis(drawing, xmap, y)
    
    for f in genes:
        if f.chrom==window.chrom and \
         (window.start<=f.start<=window.end or \
         window.start<=f.end<=window.end):
            addGene(drawing, xmap, y+20, f, fillColor=colors.blue)
    
#     for f in hmmMatches1:
#         if f.chrom==window.chrom and \
#          (window.start<=f.start<=window.end or \
#          window.start<=f.end<=window.end):
#             addGene(drawing, xmap, y+120, f, fillColor=colors.green)
#     
#     for f in hmmMatches2:
#         if f.chrom==window.chrom and \
#          (window.start<=f.start<=window.end or \
#          window.start<=f.end<=window.end):
#             addGene(drawing, xmap, y+200, f, fillColor=colors.green)
#     
#     for f in hsps:
#         if f.chrom==window.chrom and \
#          (window.start<=f.start<=window.end or \
#          window.start<=f.end<=window.end):
#             addGene(drawing, xmap, y+280, f, fillColor=colors.red)
    
    # oFilename = 'diagramsWithFeatures/%s.pdf' % cluster
    oFilename = '%s.pdf' % cluster
    renderPDF.drawToFile(drawing, oFilename, '')
    os.system('open %s' % oFilename)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:35,代码来源:draw_orig.py

示例4: drawdata

def drawdata(data, times, labels):
    drawing = Drawing(10000, 200)
    fontstep = 5.5
    for i in range(0, size(labels)):
        drawing.add(String(40,(i+9.8)*fontstep,str(labels[i]), textAnchor="middle", fontSize=5))
    #drawing.add(String(20,175,"labels", textAnchor="middle", fontSize=5))
    #data = [1, 2, 3, 4, 5, 6]
    lc = HorizontalLineChart()
    #lc.valueAxis = 0
    lc.x = 50
    lc.y = 50
    lc.height = 155
    lc.width = 10000
    lc.data = data
    lc.joinedLines = 1
    #catNames = string.split('Jan Feb Mar Apr May Jun Jul Aug', ' ')
    #catNames = times
    #lc.categoryAxis.categoryNames = catNames
    #lc.categoryAxis.labels.boxAnchor = 'n'
    lc.categoryAxis.visible = 0
    fontstep = 40
    for i in range(0, size(times)):
        drawing.add(String((i+1.3)*fontstep,45,str(times[i]), textAnchor="middle", fontSize=5))
    
    lc.lineLabelArray = ['1','2']
    #lc.valueAxis.valueMin = 0
    #lc.valueAxis.valueMax = 60

    lc.valueAxis.valueStep = 1
    #lc.valueAxis.valueSteps = [1, 2, 3, 5, 6]
    lc.lines[0].strokeWidth = .5
    lc.lines[1].strokeWidth = .5
    drawing.add(lc)
    renderPDF.drawToFile(drawing, 'example1.pdf', 'EEG data')
    return drawing, lc
开发者ID:badbytes,项目名称:pymeg,代码行数:35,代码来源:data2acrobatpdf.py

示例5: create_preamble

def create_preamble(name, style, logo):
	if ".svg" in logo:		  #check if the logo is in svg format
		tempf = open(logo, 'r')	  #open the file for reading
		s = tempf.read()
		height_k = re.search('height=\"(\d*).(\d*)', s)		  #get the height of the picture, using regular expressions
		height_l = float(re.search('\"(\d*).(\d*)', height_k.group(0)).group(0)[1:])		 #get only the height

		width_k = re.search('width=\"(\d*).(\d*)', s)			#get the width of the picture, using regular expressions
		width_l = float(re.search('\"(\d*).(\d*)', width_k.group(0)).group(0)[1:])		   #get only the width
		
		drawing = svg2rlg(logo)		 #draw the picture
		logo = logo.replace(".svg", ".pdf")		 #replace the .svg part with .pdf
		renderPDF.drawToFile(drawing, "temp/" + logo[logo.rfind("/") + 1:])			#draw the picture to the file and render it
		
	else:
		width_l, height_l = Image.open(logo).size
		if(os.path.isfile(logo)):
			shutil.copy(logo, "temp/" + logo[logo.rfind("/") + 1:])
			
	logo = logo[logo.rfind("/") + 1:]
	
	scale_height = 622.519685 / height_l
	scale_width = 418.110236 / width_l
	scale = (min(scale_height, scale_width))		 #calculate how much the logo can be scaled
	
		
	f = open("Resources/SongBookletTemplate.tex", 'r', encoding = 'utf-8')		#now create the tex file for the songbook itself

	tex = f.read()
	f.close()
	
	return tex.replace("***NAME***", name).replace("***LOGO***", logo).replace("***NUMBERING***", style).replace("***SCALE***", str(scale * 0.4))
开发者ID:CapnOdin,项目名称:PySong,代码行数:32,代码来源:preamble.py

示例6: test1_main

def test1_main():
    d = Drawing(100, 100)
    s = String(50, 50, 'BP_project2', textAnchor = 'middle')
    
    d.add(s)
    
    renderPDF.drawToFile(d, 'test_out.pdf', 'a simple PDF file')
开发者ID:satiago,项目名称:workplace,代码行数:7,代码来源:main.py

示例7: test03

def test03():
    # 最终太阳黑子图形程序
    from urllib import urlopen
    from reportlab.graphics.shapes import *
    from reportlab.graphics.charts.lineplots import LinePlot
    from reportlab.graphics.charts.textlabels import Label
    from reportlab.graphics import renderPDF

    URL = "http://services.swpc.noaa.gov/text/predicted-sunspot-radio-flux.txt"
    COMMENT_CHARS = "#:"
    drawing = Drawing(400, 200)
    data = []
    for line in urlopen(URL).readlines():
        if not line.isspace() and not line[0] in COMMENT_CHARS:
            data.append([float(n) for n in line.split()])
    pred = [row[2] for row in data]
    high = [row[3] for row in data]
    low = [row[4] for row in data]
    times = [row[0] + row[1] / 12.0 for row in data]
    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = [zip(times, pred), zip(times, high), zip(times, low)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green
    drawing.add(lp)
    drawing.add(String(250, 150, "Sunsports", fontSize=14, fillColor=colors.red))
    renderPDF.drawToFile(drawing, "report2.pdf", "Sunsports")
开发者ID:binger233,项目名称:study,代码行数:31,代码来源:21draw.py

示例8: test2_main

def test2_main():
    data = [
        (2012,12,61.2,62.2,60.2),
        (2013,1,63.2,65.2,61.2),
        (2013,2,65.3,68.3,62.3),
        (2013,3,67.5,72.5,62.5),
        (2013,4,70.1,75.1,65.1),
        (2013,5,72.7,78.7,66.7),
        (2013,6,75.7,82.7,68.7),
        (2013,7,78.6,85.6,71.6),
        (2013,8,81.6,89.6,73.6),
        (2013,9,84.7,93.7,75.7)
        ]

    drawing = Drawing(4000, 150)
    
    pred = [row[2] - 40 for row in data]
    high = [row[3] - 40 for row in data]
    low = [row[4] - 40 for row in data]
    times = [200 * ((row[0] + row[1]/12.0) - 2007) -  110 for row in data]
    
    print(times)
    print(pred)
    print(high)
    
    drawing.add(PolyLine(zip(times, pred), strokeColor = colors.blue))
    drawing.add(PolyLine(zip(times, high), strokeColor = colors.red))
    drawing.add(PolyLine(zip(times, low), strokeColor = colors.green))
    drawing.add(String(65, 115, 'Sunspots', fontSize = 18, fillColor = colors.red))

    renderPDF.drawToFile(drawing, 'report.pdf', 'Sunspots')
开发者ID:satiago,项目名称:workplace,代码行数:31,代码来源:main.py

示例9: test_12_drawingRenderPDF

    def test_12_drawingRenderPDF(self):
        from reportlab.lib import colors
        from reportlab.graphics.shapes import Drawing, Rect
        from reportlab.graphics import renderPDF

        d = Drawing(400,200)
        d.add(Rect(50,50,300,100, fillColor=colors.yellow))
        renderPDF.drawToFile(d, 'demo.pdf', 'JY.zenist.song')
开发者ID:zenist,项目名称:ZLib,代码行数:8,代码来源:test_pdf.py

示例10: save

 def save(self, file=None, format=None):
   """Hand this either a file= <filename> or
   file = <an open file object>.  
   """
   if not file:
     file = self.name
   from reportlab.graphics import renderPDF
   renderPDF.drawToFile(self.drawing, file, self.name)
开发者ID:abradle,项目名称:rdkit,代码行数:8,代码来源:pidReportLab.py

示例11: test01

def test01():
    # 生成 hello world 的PDF
    import reportlab.graphics.shapes as Rshape
    import reportlab.graphics.renderPDF as RrenderPDF

    d = Rshape.Drawing(100, 100)
    s = Rshape.String(50, 50, "Hello world!", textAnchor="middle")
    d.add(s)
    RrenderPDF.drawToFile(d, "hello.pdf", "A simple PDF file")
开发者ID:binger233,项目名称:study,代码行数:9,代码来源:21draw.py

示例12: draw

def draw():
    '''
    data=[(2007,8,113.2,114.2,112.2),
          (2007,9,112.8,115.8,109.8),
          (2007,10,111.0,116.0,106.0),
          (2007,11,109.8,116.8,102.8),
          (2007,12,107.3,115.3,99.3),
          (2008,1,105.2,114.2,96.2),
          (2008,2,104.1,114.1,94.1),
          (2008,3,99.9,110.9,88.9),
          (2008,4,94.8,106.8,82.8),
          (2008,5,91.2,104.2,78.2)]
          '''
    '''
    #这个是在pdf里画一个 hello word 的例子,
    d=Drawing(100,100)
    s=String(50,50,"hello word",textAnchor="middle")
    d.add(s)
    renderPDF.drawToFile(d,"hello.pdf","A simple PDF file")#renderPDF.drawToFile调用后会把你的pdf文件存到当前目录下一个叫hello.pdf的文件中
    '''
    URL="http://www.swpc.noaa.gov/ftpdir/weekly/Predict.txt"#见364页,这个网址记录的是太阳黑子的全部数据
    COMMENT_CHARS="#:"
    drawing=Drawing(400,200)
    data=[]
    for line in urlopen(URL).readlines():
        #not isspace()是判断 这一行不为空字符串,not line[0] in COMMENT_CHARS是说 在网页里去掉 # 和 . 的部分
        if not line.isspace() and not line[0] in COMMENT_CHARS:
            data.append([float(n) for n in line.split()])
    #print data
    
    pred=[row[2] for row in data]
    high=[row[3] for row in data]
    low=[row[4] for row in data]
    times=[row[0]+row[1]/12.0 for row in data]
    
    lp=LinePlot()
    #设置 x,y,height,width,以及data
    lp.x=50 
    lp.y=50
    lp.height=125
    lp.width=300
    lp.data=[zip(times,pred),zip(times,high),zip(times,low)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green
    
    
    '''
    drawing.add(PolyLine(zip(times,pred),storkeColor=colors.blue))
    drawing.add(PolyLine(zip(times,high),storkeColor=colors.red))
    drawing.add(PolyLine(zip(times,low),storkeColor=colors.green))
    #drawing.add(PolyLine([(10,50),(100,50),(80,80)],storkeColor=colors.red))#这个是直接画一条线
    '''
    drawing.add(lp)
    drawing.add(String(250,150,"SunSpots",fontSize=14,fillColor=colors.red))
    
    renderPDF.drawToFile(drawing,"report.pdf","SunSpots")#renderPDF.drawToFile调用后会把你的pdf文件存到当前目录下一个叫report.pdf的文件中
开发者ID:xlmysjz,项目名称:Python,代码行数:57,代码来源:Drawing.py

示例13: visit_image

 def visit_image(self, aa_image):
     """Process the given ASCIIArtFigure and output the shapes in
        the PDF file
     """
     self.aa_image = aa_image        # save for later XXX not optimal to do it here
     self.width = (aa_image.width)*aa_image.nominal_size*aa_image.aspect_ratio
     self.height = (aa_image.height)*aa_image.nominal_size
     self.drawing = Drawing(self._num(self.width), self._num(self.height))
     self.visit_shapes(aa_image.shapes)
     renderPDF.drawToFile(self.drawing, self.file_like, '')
开发者ID:Distrotech,项目名称:docutils,代码行数:10,代码来源:pdf.py

示例14: test

def test():
    """This function produces three pdf files with examples of all the signs and symbols from this file.
    """
# page 1

    labelFontSize = 10

    X = (20,245)

    flags = [
            'UK',
            'USA',
            'Afghanistan',
            'Austria',
            'Belgium',
            'Denmark',
            'Cuba',
            'Finland',
            'France',
            'Germany',
            'Greece',
            'Ireland',
            'Italy',
            'Luxembourg',
            'Holland',
            'Palestine',
            'Portugal',
            'Spain',
            'Sweden',
            'Norway',
            'CzechRepublic',
            'Turkey',
            'Switzerland',
            'EU',
            'Brazil',
            ]
    y = Y0 = 530
    f = 0
    D = None
    for name in flags:
        if not D: D = Drawing(450,650)
        flag = makeFlag(name)
        i = flags.index(name)
        flag.x = X[i%2]
        flag.y = y
        D.add(flag)
        D.add(String(flag.x+(flag.size/2),(flag.y-(1.2*labelFontSize)),
                name, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize))
        if i%2: y = y - 125
        if (i%2 and y<0) or name==flags[-1]:
            renderPDF.drawToFile(D, 'flags%02d.pdf'%f, 'flags.py - Page #%d'%(f+1))
            y = Y0
            f = f+1
            D = None
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:54,代码来源:flags.py

示例15: print_100

def print_100(file):
    d = Drawing(1000,1000)
    with open(file, 'rb') as f:

        for _ in range(3):
            print(f.readline().decode('utf-8'))
            sentence = str(f.readline().decode('utf-8'))
            s = String(10,10, sentence)
            d.add(s)

    renderPDF.drawToFile(d, 'test.pdf', 'A simple PDF file')
开发者ID:anathk,项目名称:UltimatePython,代码行数:11,代码来源:listFiles.py


注:本文中的reportlab.graphics.renderPDF.drawToFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。