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")
# -*- 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)