def dotest(outputname, nostamp): pdf = FPDF() if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.add_page() for i in range(1, 41): # for flow mode, do not pass x or y: pdf.image(os.path.join(common.basepath, '../tutorial/logo_pb.png')) pdf.output(outputname, 'F')
def dotest(outputname, nostamp): # Portrait, millimeter units, A4 page size pdf = FPDF("P", "mm", "A4") if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) # Set font: Times, normal, size 10 pdf.add_page() if not nostamp: # do not show picture in batch url = "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Code_3_of_9.svg/262px-Code_3_of_9.svg.png" pdf.image(url, 10, 10) pdf.code39("*wikipedia*", 12.75, 7, 1.49) pdf.output(outputname, 'F')
def dotest(outputname, nostamp): plane = genbar() palette = (0, 0, 0, 255, 255, 255) + (128, 128, 128) * 254 img = Image.fromstring("P", plane.size, plane.tostring()) img.putpalette(palette) with tempfile.NamedTemporaryFile(delete=False, suffix=".gif") as f: gif1 = f.name with tempfile.NamedTemporaryFile(delete=False, suffix=".gif") as f: gif2 = f.name img.save(gif1, "GIF", optimize=0) img.save(gif2, "GIF", transparency=1, optimize=0) pdf = FPDF() if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.add_page() pdf.set_font('Arial', '', 16) pdf.write(8, "Transparency") pdf.ln() pdf.write(8, " Transparency") pdf.ln() pdf.write(8, " Transparency") pdf.ln() pdf.image(gif1, x=15, y=15) pdf.write(8, "Transparency") pdf.ln() pdf.write(8, " Transparency") pdf.ln() pdf.write(8, " Transparency") pdf.ln() pdf.image(gif2, x=15, y=39) pdf.output(outputname, 'F') os.unlink(gif1) os.unlink(gif2)
def dotest(outputname, nostamp): pdf = FPDF() if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.add_page() pdf.set_font('Arial', '', 14) pdf.text(10, 57, 'DeviceGray') pdf.image(os.path.join(common.basepath, "img_gray.jpg"), 55, 5) pdf.text(10, 157, 'DeviceRGB') pdf.image(os.path.join(common.basepath, "img_rgb.jpg"), 55, 105) pdf.text(10, 257, 'DeviceCMYK') pdf.image(os.path.join(common.basepath, "img_cmyk.jpg"), 55, 205) pdf.output(outputname, 'F')
def dotest(outputname, nostamp): pdf = FPDF() if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.add_page() pdf.set_font('Arial', '', 14) pdf.ln(10) if nostamp: data = "TEST-TEST-TEST" else: data = sys.version pdf.write(5, 'hello world %s' % data) path = os.path.join(common.basepath, os.pardir, "tutorial", "logo.png") pdf.image(path, 50, 50) pdf.image(os.path.join(common.basepath, "flower2.jpg"), 100, 50) pdf.image(os.path.join(common.basepath, "lena.gif"), 50, 75) pdf.output(outputname, 'F')
"Test issue 65: twitter.png error (urlopen, transparency, internal regex error)" from gaefpdf import FPDF, FPDF_VERSION pdf=FPDF() pdf.compress = False pdf.add_page() png = "https://g.twimg.com/Twitter_logo_blue.png" pdf.image(png, x = 15, y = 15) fn = 'issue65.pdf' pdf.output(fn,'F') import os try: os.startfile(fn) except: os.system("xdg-open \"%s\"" % fn)
# -*- coding: iso-8859-1 -*- import os from gaefpdf 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)