def dotest(outputname, nostamp): try: from bidi.algorithm import get_display except ImportError: from unittest import SkipTest raise SkipTest("Need python-bidi") pdf = FPDF() if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.compress = False pdf.add_page() pdf.add_font('DejaVu', '', \ os.path.join(common.basepath, 'font/DejaVuSans.ttf'), uni=True) pdf.set_font('DejaVu', '', 14) # this will be displayed wrong as actually it is stored LTR: text= u"این یک متن پارسی است. This is a Persian text !!" pdf.write(8, text) pdf.ln(8) # Reverse the RLT using the Bidirectional Algorithm to be displayed correctly: # (http://unicode.org/reports/tr9/) rtl_text = get_display(text) pdf.write(8, rtl_text) pdf.output(outputname, 'F')
def dotest(outputname, nostamp): pdf = FPDF(orientation="L", format="A5") pdf.compress = False if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.set_font('Arial', '', 14) for i in range(10): o = ["p", "L", "P", "l"][i % 4] page(pdf, "Page %d from 10\nOrientation: %s" % (i + 1, o), o) pdf.output(outputname, 'F')
def dotest(outputname, nostamp): pdf = FPDF(orientation="L", format=(100, 250)) pdf.compress = False if nostamp: pdf._putinfo = lambda: common.test_putinfo(pdf) pdf.set_font('Arial', '', 14) for i in range(16): o = ["p", "l"][i % 2] f = ["a3", "a4", "a5", "letter", "legal", "", (100, 250), (320, 240)][i % 8] page(pdf, "Page %d from 16\nFormat: %s\nOrientation: %s" % (i + 1, f, o), o, f) 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)