def do_it(): prof = jagpdf.create_profile_from_string(s_profile) stream = testlib.NoopStreamOut() doc = jagpdf.create_stream(stream) doc.page_start(5.9*72, 3.5*72) canvas = doc.page().canvas() # meat img = doc.image_load_file(s_jpeg_file) canvas.image(img, 50, 50) canvas.text(10, 10, 200 * 'a') canvas.move_to(10, 10) canvas.line_to(20, 20) canvas.path_paint("fs") font_ttf = testlib.EasyFontTTF(doc)(10) font_core = testlib.EasyFont(doc)(10) canvas.text_font(font_ttf) canvas.text(10, 10, 50 * 'x') font_ttf.advance('abcdefghijklmnopqrstuvwxyz') canvas.text_font(font_core) canvas.text(10, 10, 50 * 'y') font_core.advance('abcdefghijklmnopqrstuvwxyz') # finalize doc.page_end() doc.finalize() # touch the result s = 0 for b in stream.content(): s = s + ord(b)
def test_main(argv=None): if None == argv: argv = sys.argv out_file = os.path.abspath(os.path.join(argv[1], 'config.pdf')) cfg_file = os.path.abspath(os.path.join(argv[1], 'config.ini')) doc = jagpdf.create_stream(testlib.FileStreamOut(out_file)) doc = None doc = jagpdf.create_file(out_file) doc = None cfg = jagpdf.create_profile() cfg.set("doc.compressed", "blue-foundation") cfg.save_to_file(out_file) cfg_str = open(out_file).read() cfg3 = jagpdf.create_profile_from_file(out_file) cfg2 = jagpdf.create_profile_from_string(cfg_str) cfg3.save_to_file(cfg_file) cfg3_str = open(cfg_file).read() cfg2.save_to_file(cfg_file) cfg2_str = open(cfg_file).read() os.unlink(out_file) os.unlink(cfg_file) assert cfg3_str == cfg2_str
def test_main(argv=None): if None==argv: argv = sys.argv out_file = os.path.abspath(os.path.join(argv[1], 'config.pdf')) cfg_file = os.path.abspath(os.path.join(argv[1], 'config.ini')) doc = jagpdf.create_stream(testlib.FileStreamOut(out_file)) doc = None doc = jagpdf.create_file(out_file) doc = None cfg = jagpdf.create_profile() cfg.set("doc.compressed", "blue-foundation") cfg.save_to_file(out_file) cfg_str = open(out_file).read() cfg3 = jagpdf.create_profile_from_file(out_file) cfg2 = jagpdf.create_profile_from_string(cfg_str) cfg3.save_to_file(cfg_file) cfg3_str = open(cfg_file).read() cfg2.save_to_file(cfg_file) cfg2_str = open(cfg_file).read() os.unlink(out_file) os.unlink(cfg_file) assert cfg3_str == cfg2_str