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 do_doc(argv, docname, profile=None): doc = testlib.create_test_doc(argv, docname, profile) font = testlib.EasyFontTTF(doc) font_core = testlib.EasyFont(doc) basic(doc, font, font_core) merge(doc, font_core(12)) merge(doc, font(12)) format(doc, font_core(12), 'justify') format(doc, font_core(12), 'left') format(doc, font(12), 'justify') format(doc, font(12), 'left') doc.finalize()
def test_main(argv=None): ## ## default text encoding: utf-8 ## font encoding: windows-1250 ## cfg = testlib.test_config() cfg.set("text.encoding", "utf-8") doc = testlib.create_test_doc(argv, "defaulttxtenc.pdf", cfg) #doc = testlib.create_test_doc("/mnt/win/c/Temp/basictxtfmt3.pdf", cfg) do_page(doc, testlib.EasyFont(doc, 'windows-1250'), testlib.long_unicode_text, "core font 1250, text utf-8") do_page(doc, testlib.EasyFontTTF(doc, 'windows-1250'), testlib.long_unicode_text, "ttf 1250, text utf-8") doc.finalize() ## ## default text encoding: windows-1250 ## font encoding: iso-8859-2 ## cfg = testlib.test_config() cfg.set("text.encoding", "windows-1250") doc = testlib.create_test_doc(argv, "defaulttxtenc2.pdf", cfg) #doc = testlib.create_test_doc("/mnt/win/c/Temp/defaulttxtenc2.pdf", cfg) do_page(doc, testlib.EasyFont(doc, 'iso-8859-2'), testlib.long_unicode_text.encode("windows-1250"), "core font iso-8859-2, windows-1250") do_page(doc, testlib.EasyFontTTF(doc, 'iso-8859-2'), testlib.long_unicode_text.encode("windows-1250"), "ttf iso-8859-2, windows-1250") doc.finalize()
def test_main(argv=None): doc = testlib.create_test_doc(argv, "basictxtfmt.pdf") g_fnt_1250 = testlib.EasyFont(doc, 'windows-1250') g_fnt_ttf_utf8 = testlib.EasyFontTTF(doc, 'utf-8') g_fnt_utf8 = doc.font_load("standard; name=Helvetica; size=12; enc=utf-8") txt = testlib.long_text utxt = testlib.long_unicode_text do_page(doc, utxt, g_fnt_ttf_utf8(12), "ttf pyunicode", align="justify") do_page(doc, txt, g_fnt_1250(12), "core cp1250") do_page(doc, txt, g_fnt_1250(12), "core cp1250 - justified", align="justify") do_page(doc, txt, g_fnt_1250(12), "core cp1250 - right align", align="right") do_page(doc, txt, g_fnt_1250(12), "core cp1250 - center align", align="center") do_page(doc, txt, g_fnt_1250(12), "core cp1250 - bottomup", direction='bottomup') do_page(doc, utxt.encode('windows-1250'), g_fnt_1250(12), "core cp1250 (from unicode)", baseline="top", align="justify") do_page(doc, utxt, g_fnt_utf8, "core unicode", baseline="top", align="justify") doc.finalize()
#!/usr/bin/env python # # Copyright (c) 2005-2009 Jaroslav Gresula # # Distributed under the MIT license (See accompanying file # LICENSE.txt or copy at http://jagpdf.org/LICENSE.txt) # import jagpdf import sys import os import jag.testlib as testlib g_font = testlib.EasyFontTTF() #raw_input("attach") def do_some(doc): doc.page_start(5.9 * 72, 5.9 * 72) page = doc.page().canvas() page.color("fs", 0.75) page.rectangle(20, 20, 72, 72) page.path_paint('s') page.text_font(g_font(8)) page.text(25, 57, "a gray rectangle") page.text(25, 45, "www.boost.org") doc.page().annotation_uri(20, 20, 72, 72, "http://www.boost.org") doc.page_end()