コード例 #1
0
ファイル: form.py プロジェクト: Blurjp/HuangDaxi
    def render(self, outfile):
        pdf = FPDF()
        pdf.add_page()
        pdf.set_font('Arial', 'B', 16)

        for field in self.fields.values():
            self.handlers[field['type'].upper()](pdf, **field)

        pdf.output(outfile, "F")
コード例 #2
0
ファイル: form.py プロジェクト: BitCurator/bitcurator
    def render(self, outfile):
        pdf = FPDF()
        pdf.add_page();
        pdf.set_font('Arial','B',16);

        for field in self.fields.values():
            self.handlers[field['type'].upper()](pdf, **field)

        pdf.output(outfile,"F")
コード例 #3
0
ファイル: hardcoded-invoice.py プロジェクト: Blurjp/HuangDaxi
# -*- coding: iso-8859-1 -*-

import os
from pyfpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.set_font('helvetica', '', 13.0)
pdf.set_xy(105.0, 8.0)
pdf.cell(ln=0, h=22.0, align='C', w=75.0, txt='Sample Invoice', border=0)
pdf.set_line_width(0.0)
pdf.rect(15.0, 15.0, 170.0, 245.0)
pdf.set_line_width(0.0)
pdf.rect(95.0, 15.0, 10.0, 10.0)
pdf.image('../tutorial/logo.png', 20.0, 17.0, link='', type='', w=13.0, h=13.0)
pdf.set_font('arial', 'B', 16.0)
pdf.set_xy(95.0, 18.0)
pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='X', border=0)
pdf.set_font('arial', '', 8.0)
pdf.set_xy(105.0, 21.0)
pdf.cell(ln=0, h=4.0, align='C', w=75.0, txt='Original', border=0)
pdf.set_font('arial', 'B', 7.0)
pdf.set_xy(95.0, 21.5)
pdf.cell(ln=0, h=4.5, align='C', w=10.0, txt='COD.00', border=0)
pdf.set_line_width(0.0)
pdf.line(100.0, 25.0, 100.0, 57.0)
pdf.set_font('arial', 'B', 14.0)
pdf.set_xy(125.0, 25.5)
pdf.cell(ln=0, h=9.5, align='L', w=60.0, txt='00000001', border=0)
pdf.set_xy(115.0, 27.5)
pdf.cell(ln=0, h=5.5, align='L', w=10.0, txt='N\xba: ', border=0)
コード例 #4
0
ファイル: hardcoded-invoice.py プロジェクト: Blurjp/HuangDaxi
# -*- coding: iso-8859-1 -*-

import os
from pyfpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.set_font('helvetica', '', 13.0)
pdf.set_xy(105.0, 8.0)
pdf.cell(ln=0, h=22.0, align='C', w=75.0, txt='Sample Invoice', border=0)
pdf.set_line_width(0.0)
pdf.rect(15.0, 15.0, 170.0, 245.0)
pdf.set_line_width(0.0)
pdf.rect(95.0, 15.0, 10.0, 10.0)
pdf.image('../tutorial/logo.png', 20.0, 17.0, link='', type='', w=13.0, h=13.0)
pdf.set_font('arial', 'B', 16.0)
pdf.set_xy(95.0, 18.0)
pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='X', border=0)
pdf.set_font('arial', '', 8.0)
pdf.set_xy(105.0, 21.0)
pdf.cell(ln=0, h=4.0, align='C', w=75.0, txt='Original', border=0)
pdf.set_font('arial', 'B', 7.0)
pdf.set_xy(95.0, 21.5)
pdf.cell(ln=0, h=4.5, align='C', w=10.0, txt='COD.00', border=0)
pdf.set_line_width(0.0)
pdf.line(100.0, 25.0, 100.0, 57.0)
pdf.set_font('arial', 'B', 14.0)
pdf.set_xy(125.0, 25.5)
pdf.cell(ln=0, h=9.5, align='L', w=60.0, txt='00000001', border=0)
pdf.set_xy(115.0, 27.5)
pdf.cell(ln=0, h=5.5, align='L', w=10.0, txt='N\xba: ', border=0)
コード例 #5
0
def generate_pdf(track_list=None, output='output.pdf', short_name='CD001', long_name='CD Cover'):
    v_print('generating pdf')

    # Initialize PDF
    pdf=FPDF(unit='mm', format=(120,120))

    # Set Margins
    pdf.set_left_margin(0)
    pdf.set_top_margin(0)
    pdf.set_right_margin(0)
    pdf.set_auto_page_break(False,margin=0)

    # Start Page
    pdf.add_page()

    v_print('drawing album art')

    # Album art boxes
    for y in range(4):
        for x in range(2):
            pdf.set_xy(30 * x ,30 * y)
            pdf.set_font('Arial','B',16)

            # Print album art
            if len(track_list) > (x*4 + y):
                pdf.image(name = track_list[x*4 + y]['image'], type = what(track_list[x*4 + y]['image']), x=30 * x , y=30 * y, w=30, h=30)


    v_print('drawing cd titles')

    # Print title of cd
    pdf.set_xy(65,2)
    pdf.set_font('Arial','B',36)
    pdf.cell(w=50, h=12, txt=short_name, border=0, align='C', fill=False)

    # Print subtitle of cd
    pdf.set_xy(65,14)
    pdf.set_font('Arial','B',10)
    pdf.cell(w=50, h=5, txt=long_name, border=1, align='C', fill=False)


    v_print('drawing tracklist')

    # Print tracklist
    for y in range(len(track_list)):
        pdf.set_xy(62,23 + 12*y)

        # Line 1
        pdf.set_font('Arial','B',10)
        pdf.cell(w=50, h=4, txt=str(y+1) + ': ' + track_list[y]['title'], border=0, align='L', fill=False, ln='2')

        # Line 2
        line2 = '      '
        line2 = line2 + track_list[y]['artist']
        pdf.set_font('Arial','',8)
        pdf.cell(w=50, h=3, txt=line2, border=0, align='L', fill=False, ln='2')

        # Line 3
        line3 = '      ' 
        if(track_list[y]['bpm']):
            line3 = line3 + track_list[y]['bpm'] +'BPM ' 
        if(track_list[y]['initial_key']):
            line3 = line3 + track_list[y]['initial_key']
        if(track_list[y]['label']):
            line3 = line3 + ' [' + track_list[y]['label'] + ']'
        pdf.cell(w=50, h=3, txt=line3, border=0, align='L', fill=False)

    v_print('writing pdf file to ' + output)

    # Write pdf file
    pdf.output(output,'F')
コード例 #6
0
ファイル: PDFGENERATE.py プロジェクト: fahdanwar/PDFGENRATOR
with open("fake.csv","r+b") as f:
     lis=[list(x.split(",")) for x in f]
     #mapout=mmap.mmap(f.fileno(),0)
     #L=list()
     #lis=[list(map(int,x.split(","))) for x in f]
     #for s in iter(mapout.readline,""):
      #    L.append(s)
     #print "List Length: ",len(lis)
     #print "List: ",lis[1][2]
#input("ENTER")
length=len(lis)-1;
for p in range(0,10000000):
    i=0
    j=22
    k=000000001
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font('helvetica', '', 13.0)
    pdf.set_xy(105.0, 8.0)
    pdf.cell(ln=0, h=22.0, align='C', w=75.0, txt='Invoice# %s'%lis[random.randint(0,length)][0], border=0)
    pdf.set_line_width(0.0)
    pdf.rect(15.0, 15.0, 170.0, 245.0)
    pdf.set_line_width(0.0)
    pdf.rect(95.0, 15.0, 10.0, 10.0)
    #pdf.image('./logo.png', 20.0, 17.0, link='', type='', w=13.0, h=13.0)
    pdf.set_font('arial', 'B', 16.0)
    pdf.set_xy(95.0, 18.0)
    pdf.cell(ln=0, h=2.0, align='C', w=10.0, txt='X', border=0)
    pdf.set_font('arial', '', 8.0)
    pdf.set_xy(105.0, 21.0)
    pdf.cell(ln=0, h=4.0, align='C', w=75.0, txt=lis[random.randint(0,length)][7], border=0)