Exemplo 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")
Exemplo 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")
Exemplo n.º 3
0
# -*- 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)
Exemplo n.º 4
0
# -*- 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)
Exemplo 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')