Ejemplo n.º 1
0
    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")
Ejemplo n.º 2
0
    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")
Ejemplo n.º 3
0
pdf.set_font('arial', '', 10.0)
pdf.set_xy(20.0, 238.0)
pdf.cell(ln=0, h=5.0, align='L', w=95.0, txt='Fecha Vto. CAE:', border=0)
pdf.set_xy(55.0, 238.0)
pdf.cell(ln=0, h=5.0, align='L', w=30.0, txt='19/02/2009', border=0)
pdf.set_font('arial', '', 12.0)
pdf.set_xy(125.0, 241.0)
pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='VAT 21%:', border=0)
pdf.set_font('arial', 'B', 12.0)
pdf.set_xy(145.0, 241.0)
pdf.cell(ln=0, h=9.0, align='R', w=33.0, txt='21,00', border=0)
pdf.interleaved2of5('012345678905', 20.0, 243.5, w=0.75)
pdf.set_font('arial', 'B', 12.0)
pdf.set_xy(105.0, 251.0)
pdf.cell(ln=0, h=9.0, align='R', w=73.0, txt='121,00', border=0)
pdf.set_font('arial', '', 12.0)
pdf.set_xy(125.0, 251.0)
pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='Total:', border=0)
pdf.set_line_width(0.0)
pdf.rect(155.0, 252.0, 25.0, 7.0)
pdf.set_font('courier', '', 10.0)
pdf.set_xy(20.0, 253.0)
pdf.cell(ln=0, h=7.0, align='L', w=120.0, txt='012345678905', border=0)
pdf.output('./invoice.pdf', 'F')

import sys
if sys.platform.startswith("linux"):
    os.system("evince ./invoice.pdf")
else:
    os.system("./invoice.pdf")
Ejemplo n.º 4
0
pdf.set_font('arial', '', 10.0)
pdf.set_xy(20.0, 238.0)
pdf.cell(ln=0, h=5.0, align='L', w=95.0, txt='Fecha Vto. CAE:', border=0)
pdf.set_xy(55.0, 238.0)
pdf.cell(ln=0, h=5.0, align='L', w=30.0, txt='19/02/2009', border=0)
pdf.set_font('arial', '', 12.0)
pdf.set_xy(125.0, 241.0)
pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='VAT 21%:', border=0)
pdf.set_font('arial', 'B', 12.0)
pdf.set_xy(145.0, 241.0)
pdf.cell(ln=0, h=9.0, align='R', w=33.0, txt='21,00', border=0)
pdf.interleaved2of5('012345678905', 20.0, 243.5, w=0.75)
pdf.set_font('arial', 'B', 12.0)
pdf.set_xy(105.0, 251.0)
pdf.cell(ln=0, h=9.0, align='R', w=73.0, txt='121,00', border=0)
pdf.set_font('arial', '', 12.0)
pdf.set_xy(125.0, 251.0)
pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='Total:', border=0)
pdf.set_line_width(0.0)
pdf.rect(155.0, 252.0, 25.0, 7.0)
pdf.set_font('courier', '', 10.0)
pdf.set_xy(20.0, 253.0)
pdf.cell(ln=0, h=7.0, align='L', w=120.0, txt='012345678905', border=0)
pdf.output('./invoice.pdf', 'F')

import sys
if sys.platform.startswith("linux"):
    os.system("evince ./invoice.pdf")
else:
    os.system("./invoice.pdf")
Ejemplo n.º 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')
Ejemplo n.º 6
0
    pdf.set_font('arial', '', 10.0)
    pdf.set_xy(20.0, 238.0)
    pdf.cell(ln=0, h=5.0, align='L', w=95.0, txt='Fecha Vto. CAE:', border=0)
    pdf.set_xy(55.0, 238.0)
    random_day = date.fromordinal(random.randint(start_date, end_date))
    pdf.cell(ln=0, h=5.0, align='L', w=30.0, txt=random_day.strftime('%m/%d/%Y'), border=0)
    pdf.set_font('arial', '', 12.0)
    pdf.set_xy(125.0, 241.0)
    pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='VAT 21%:', border=0)
    pdf.set_font('arial', 'B', 12.0)
    pdf.set_xy(145.0, 241.0)
    pdf.cell(ln=0, h=9.0, align='R', w=33.0, txt='%d'%random.randint(0,1000000), border=0)
    pdf.interleaved2of5('012345678905', 20.0, 243.5, w=0.75)
    pdf.set_font('arial', 'B', 12.0)
    pdf.set_xy(105.0, 251.0)
    pdf.cell(ln=0, h=9.0, align='R', w=73.0, txt='%d'%random.randint(0,1000000), border=0)
    pdf.set_font('arial', '', 12.0)
    pdf.set_xy(125.0, 251.0)
    pdf.cell(ln=0, h=9.0, align='R', w=25.0, txt='Total:', border=0)
    pdf.set_line_width(0.0)
    pdf.rect(155.0, 252.0, 25.0, 7.0)
    pdf.set_font('courier', '', 10.0)
    pdf.set_xy(20.0, 253.0)
    pdf.cell(ln=0, h=7.0, align='L', w=120.0, txt=lis[random.randint(0,length)][12], border=0)
    pdf.output('%d.pdf'%p, 'F')
    print(p)
    

    #import sys
    #os.system("./invoice.pdf")