Exemplo n.º 1
0
def do_main(argv):
    out_files = ["customsmask15.pdf",
                  "customsmask14.pdf",
                  "customsmask13.pdf"]
    # (2,3,1) - removed
    for index, version, strict in [(1,4,1), (0,5,1), (2,3,0)]:
        if version < 4 and strict:
            checker = testlib.must_throw
            cfg = testlib.test_config()
            cfg.set("doc.version", str(version))
            cfg.set("doc.strict_mode", str(strict))
            cfg.set("images.softmask_16_to_8", str(0))
            doc = jagpdf.create_stream(testlib.NoopStreamOut(), cfg)
        else:
            checker = lambda fn, *args: fn(*args)
        doc, cfg = testlib.get_legacy_doc(argv,
                                           out_files[index],
                                           { 'doc.version' : version,
                                             'doc.strict_mode' : strict,
                                             'images.softmask_16_to_8' : 0 })
        g_font.set_writer(doc)
        g_softmask.set_doc(doc)
        checker(do_grayscale, doc)
        checker(do_rgb, doc)
        checker(do_cmyk, doc)
        doc.finalize()
Exemplo n.º 2
0
def do_main(argv=None):
    out_files = ["customimage15.pdf",\
                  "customimage14.pdf",\
                  "customimage13.pdf",\
                  "customimage12.pdf"]
    # (0,2,1) - removed
    for index, version, strict in [(3,2,0), (2,3,1), (1,4,1), (0,5,1)]:
        if strict and version == 2:
            # it seems that this test branch is flawed as the
            # exceptions are raised in different places then
            # originally inteded
            checker = testlib.must_throw
            cfg = testlib.test_config()
            cfg.set("doc.version", str(version))
            cfg.set("doc.strict_mode", str(strict))
            doc = jagpdf.create_as_stream(testlib.NoopStreamOut(), cfg)
        else:
            checker = lambda fn, *args: fn(*args)
            doc, cfg = testlib.get_legacy_doc(argv,
                                              out_files[index],
                                              {'doc.version':version,
                                               'doc.strict_mode':strict})
        g_font.set_writer(doc)
        checker(g_hardmask.set_doc, doc)
        checker(do_grayscale, doc)
        checker(do_rgb, doc)
        checker(do_cmyk, doc)
        checker(do_cielab, doc)
        checker(do_indexed, doc)
        check_errors(doc)
        doc.finalize()
Exemplo n.º 3
0
def do_main(argv=None):
    out_files = ["customimage15.pdf",\
                  "customimage14.pdf",\
                  "customimage13.pdf",\
                  "customimage12.pdf"]
    # (0,2,1) - removed
    for index, version, strict in [(3, 2, 0), (2, 3, 1), (1, 4, 1), (0, 5, 1)]:
        if strict and version == 2:
            # it seems that this test branch is flawed as the
            # exceptions are raised in different places then
            # originally inteded
            checker = testlib.must_throw
            cfg = testlib.test_config()
            cfg.set("doc.version", str(version))
            cfg.set("doc.strict_mode", str(strict))
            doc = jagpdf.create_as_stream(testlib.NoopStreamOut(), cfg)
        else:
            checker = lambda fn, *args: fn(*args)
            doc, cfg = testlib.get_legacy_doc(argv, out_files[index], {
                'doc.version': version,
                'doc.strict_mode': strict
            })
        g_font.set_writer(doc)
        checker(g_hardmask.set_doc, doc)
        checker(do_grayscale, doc)
        checker(do_rgb, doc)
        checker(do_cmyk, doc)
        checker(do_cielab, doc)
        checker(do_indexed, doc)
        check_errors(doc)
        doc.finalize()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set("doc.version", "6")
    # CFF is extracted even in 1.6, see #98
    do_doc(argv, 'opentypecff16.pdf', cfg, "OpenType CFF.")

    cfg.set("doc.version", "5")
    do_doc(argv, 'opentypecff15.pdf', cfg, "CFF extracted from OpenType.")
Exemplo n.º 6
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set("doc.version", "6")
    # CFF is extracted even in 1.6, see #98
    do_doc(argv, 'opentypecff16.pdf', cfg, "OpenType CFF.")

    cfg.set("doc.version", "5")
    do_doc(argv, 'opentypecff15.pdf', cfg, "CFF extracted from OpenType.")
Exemplo n.º 7
0
def test_main(argv=None):
    profile = testlib.test_config()
    profile.set("info.title", "This title should be overwritten.")
    profile.set("doc.viewer_preferences", "DisplayDocTitle")
    doc = testlib.create_test_doc(argv, 'doctitle.pdf', profile)
    doc.page_start(100, 100)
    doc.title("A new title.")
    doc.page_end()
    doc.finalize()
Exemplo n.º 8
0
def test_main(argv=None):
    profile = testlib.test_config()
    profile.set("info.title", "This title should be overwritten.")
    profile.set("doc.viewer_preferences", "DisplayDocTitle")
    doc = testlib.create_test_doc(argv, 'doctitle.pdf', profile)
    doc.page_start(100, 100)
    doc.title("A new title.")
    doc.page_end()
    doc.finalize()
Exemplo n.º 9
0
def test_main(argv=None):
    profile = testlib.test_config()
    profile.set("doc.encryption", "standard")
    profile.set("doc.static_file_id", "1")
    profile.set("info.creation_date", "0")
    profile.set("info.static_producer", "1")
    doc = testlib.create_test_doc(argv, 'encrypted_indexed_cs.pdf', profile)
    do(doc)
    doc.finalize()
Exemplo n.º 10
0
def test_main(argv=None):
    if None == argv:
        argv = sys.argv
    out_file = os.path.abspath(os.path.join(argv[1], 'basic_extstream.pdf'))
    cfg = testlib.test_config()
    doc = jagpdf.create_stream(testlib.FileStreamOut(out_file), cfg)
    doc.page_start(5.9*72, 3.5*72)
    writer = doc.page().canvas()
    doc.page_end()
    doc.finalize()
    doc = None
Exemplo n.º 11
0
def test_main(argv=None):
    #do_file(argv, "topdown2_off.pdf")
    profile = testlib.test_config()
    profile.set('doc.topdown', "1")
    do_file(argv, "topdown2_on.pdf", profile)
    profile.set('doc.encryption', 'standard')
    profile.set('stdsh.pwd_user', 'user')
    profile.set('stdsh.pwd_owner', 'owner')
    profile.set('info.static_producer', '1')
    profile.set('info.creation_date', '0')
    do_file(argv, "topdown2_on_enc.pdf", profile)
Exemplo n.º 12
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('info.title', 'title: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.author', 'author: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.subject', 'subject: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.keywords', 'keywords: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.creator', 'creator: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    doc = testlib.create_test_doc(argv, 'infodict.pdf', cfg)
    doc.page_start(400, 400)
    doc.page_end()
    doc.finalize()
Exemplo n.º 13
0
def test_main(argv=None):
    cfg = testlib.test_config()
    #cfg.set("doc.trace_level", "5")
    doc = testlib.create_test_doc(argv, 'annots.pdf', cfg)
    g_font.set_writer(doc)
    do_some(doc)
    do_goto_single_page(doc)
    do_goto_each_other(doc)
    do_outline_and_goto(doc)

    doc.finalize()
Exemplo n.º 14
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('info.title', 'title: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.author', 'author: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.subject', 'subject: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.keywords', 'keywords: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    cfg.set('info.creator', 'creator: ' + 'p\xc5\x99\xc3\xadli\xc5\xa1')
    doc = testlib.create_test_doc(argv, 'infodict.pdf', cfg)
    doc.page_start(400, 400)
    doc.page_end()
    doc.finalize()
Exemplo n.º 15
0
def test_main(argv=None):
    if None == argv:
        argv = sys.argv
    out_file = os.path.abspath(os.path.join(argv[1], 'basic_extstream.pdf'))
    cfg = testlib.test_config()
    doc = jagpdf.create_stream(testlib.FileStreamOut(out_file), cfg)
    doc.page_start(5.9 * 72, 3.5 * 72)
    writer = doc.page().canvas()
    doc.page_end()
    doc.finalize()
    doc = None
Exemplo n.º 16
0
def test_main(argv=None):
    cfg = testlib.test_config()
    #cfg.set("doc.trace_level", "5")
    doc = testlib.create_test_doc(argv, 'annots.pdf', cfg)
    g_font.set_writer(doc)
    do_some(doc)
    do_goto_single_page(doc)
    do_goto_each_other(doc)
    do_outline_and_goto(doc)

    doc.finalize()
Exemplo n.º 17
0
def test_main(argv=None):
    out_files = ["png-test-suite15.pdf",
                  "png-test-suite14.pdf",
                  "png-test-suite13.pdf",
                  "png-test-suite12.pdf"]
    cfg = testlib.test_config()
    for i, ver in [(0,5), (1,4), (2,3), (3,2)]:
        cfg.set('doc.version', str(ver))
        doc_writer = testlib.create_test_doc(argv, out_files[i], cfg)
        g_font.set_writer(doc_writer)
        do_suite(doc_writer)
        test_corrupted_files(doc_writer)
        doc_writer.finalize()
Exemplo n.º 18
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set("fonts.subset", "0")
    doc = testlib.create_test_doc(argv, 'nosubset.pdf', cfg)
    spec = 'enc=windows-1252; size=12; file=${JAG_TEST_RESOURCES_DIR}/fonts/DejaVuSansMono.ttf'
    fspec = os.path.expandvars(spec)
    fontid = doc.font_load(fspec)
    doc.page_start(3.5*72, 3.5*72)
    writer = doc.page().canvas()
    writer.text_font(fontid)
    writer.text(20, 20, "Monospaced font.")
    doc.page_end()
    doc.finalize()
Exemplo n.º 19
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set("fonts.subset", "0")
    doc = testlib.create_test_doc(argv, 'nosubset.pdf', cfg)
    spec = 'enc=windows-1252; size=12; file=${JAG_TEST_RESOURCES_DIR}/fonts/DejaVuSansMono.ttf'
    fspec = os.path.expandvars(spec)
    fontid = doc.font_load(fspec)
    doc.page_start(3.5 * 72, 3.5 * 72)
    writer = doc.page().canvas()
    writer.text_font(fontid)
    writer.text(20, 20, "Monospaced font.")
    doc.page_end()
    doc.finalize()
Exemplo n.º 20
0
def test_main(argv=None):
    out_files = [
        "png-test-suite15.pdf", "png-test-suite14.pdf", "png-test-suite13.pdf",
        "png-test-suite12.pdf"
    ]
    cfg = testlib.test_config()
    for i, ver in [(0, 5), (1, 4), (2, 3), (3, 2)]:
        cfg.set('doc.version', str(ver))
        doc_writer = testlib.create_test_doc(argv, out_files[i], cfg)
        g_font.set_writer(doc_writer)
        do_suite(doc_writer)
        test_corrupted_files(doc_writer)
        doc_writer.finalize()
Exemplo n.º 21
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('images.default_dpi', '92')
    doc_writer = testlib.create_test_doc(argv, 'img-jpeg.pdf', cfg)
    g_font.set_writer(doc_writer)
    do_jfif_96(doc_writer)
    do_exif_little_endian_srgb(doc_writer)
    do_exif_little_endian(doc_writer)
    do_lenghty_icc(doc_writer)
    do_jpeg_cmyk(doc_writer)
    do_simple_icc(doc_writer)
    do_basic_page(doc_writer)
    doc_writer.finalize()
Exemplo n.º 22
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('images.default_dpi', '92')
    doc_writer = testlib.create_test_doc(argv, 'img-jpeg.pdf',cfg)
    g_font.set_writer(doc_writer)
    do_jfif_96(doc_writer)
    do_exif_little_endian_srgb(doc_writer)
    do_exif_little_endian(doc_writer)
    do_lenghty_icc(doc_writer)
    do_jpeg_cmyk(doc_writer)
    do_simple_icc(doc_writer)
    do_basic_page(doc_writer)
    doc_writer.finalize()
Exemplo n.º 23
0
def graphics_state(argv):
    # do not send unnecessary set font operators
    profile = testlib.test_config()
    profile.set("doc.compressed", "0")
    doc = testlib.create_test_doc(argv, 'adobefont_grstate.pdf', profile)
    fnt = doc.font_load("standard; name=Helvetica; size=12; enc=utf-8")
    doc.page_start(200, 200)
    canvas = doc.page().canvas()
    canvas.text_font(fnt)
    canvas.text_start(20, 50)
    canvas.text('first')
    canvas.text(' second')
    canvas.text_end()
    doc.page_end()
    doc.finalize()
Exemplo n.º 24
0
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()
Exemplo n.º 25
0
def graphics_state(argv):
    # do not send unnecessary set font operators
    profile = testlib.test_config()
    profile.set("doc.compressed", "0")
    doc = testlib.create_test_doc(argv, 'adobefont_grstate.pdf', profile)
    fnt = doc.font_load("standard; name=Helvetica; size=12; enc=utf-8")
    doc.page_start(200, 200)
    canvas = doc.page().canvas()
    canvas.text_font(fnt)
    canvas.text_start(20,50)
    canvas.text('first')
    canvas.text(' second')
    canvas.text_end()
    doc.page_end()
    doc.finalize()
Exemplo n.º 26
0
def basic_test(argv):
    lines = [
        "Jag kan äta glas utan att skada mig.",
        "Rødgrød med mælk og fløde på.",
        "Příliš žluťoučký kůň úpěl ďábelské ódy.", "Single encoding."
    ]
    profile = testlib.test_config()
    profile.set("doc.trace_level", "2")
    doc = testlib.create_test_doc(argv, 'adobefont_unicode.pdf', profile)
    fnt = doc.font_load("standard; name=Helvetica; size=12; enc=utf-8")
    doc.page_start(500, 500)
    canvas = doc.page().canvas()
    canvas.text_font(fnt)
    # n texts
    for line, y in zip(lines, [110, 90, 70, 50]):
        canvas.text(50, y, line)
    # single multiline text
    canvas.text_start(50, 150)
    for line in lines:
        canvas.text(line)
        canvas.text_translate_line(0, 15)
    canvas.text_end()
    # all in one line
    fnt_8 = doc.font_load("standard; name=Helvetica; size=8; enc=utf-8")
    canvas.text_font(fnt_8)
    joined = " ".join(lines)
    rect_w = fnt_8.advance(joined)
    # enable the following lines to see BANG
    canvas.state_save()
    canvas.color('s', 0.5)
    canvas.rectangle(10, 250, rect_w, 100)
    canvas.path_paint('s')
    canvas.state_restore()
    canvas.text(10, 300, joined)
    # full justification
    t = unicode(lines[1] + ' ' + lines[2], 'utf-8')
    w = fnt_8.advance(t)
    spaces = [i for i in range(len(t)) if t[i] == u' ']
    nr_spaces = len(spaces)
    padd = -(1000 / fnt_8.size()) * (rect_w - w) / nr_spaces
    positions = [padd for i in range(nr_spaces)]
    canvas.text(10, 320, t, positions, spaces)
    #
    canvas.text(10, 400, "Cyrillic >\xd0\x96\xd1\x86\xd0\xba<")
    #
    check_font_metrics(doc)
    doc.page_end()
    doc.finalize()
Exemplo n.º 27
0
def test_main(argv=None):
    cfg = testlib.test_config()

    # normal functionality
    cfg.set('doc.version', "3")
    writer = testlib.create_test_doc(argv,'color-space-str-def.pdf', cfg)
    g_font.set_writer(writer)
    do_page(writer)
    writer.finalize()

    # expected failures
    cfg.set('doc.version', "2")
    writer = jagpdf.create_stream(testlib.NoopStreamOut(), cfg)
    g_font.set_writer(writer)
    do_failures_v2(writer)
    writer.finalize()
Exemplo n.º 28
0
def do_document(argv, name, cfg_opts):
    cfg = testlib.test_config()
    for k, v in cfg_opts.iteritems():
        cfg.set(k, v)
    doc = testlib.create_test_doc(argv, name + '.pdf', cfg)
    doc.page_start(400, 400)
    canvas = doc.page().canvas()
    canvas.text_start(20, 380)
    l = [(k, v) for k, v in cfg_opts.iteritems()]
    l.sort()
    for k, v in l:
        canvas.text("%s : %s" % (k, v))
        canvas.text_translate_line(0, -15)
    canvas.text_end()
    doc.page_end()
    doc.finalize()
Exemplo n.º 29
0
def test_main(argv=None):
    cfg = testlib.test_config()

    # normal functionality
    cfg.set('doc.version', "3")
    writer = testlib.create_test_doc(argv, 'color-space-str-def.pdf', cfg)
    g_font.set_writer(writer)
    do_page(writer)
    writer.finalize()

    # expected failures
    cfg.set('doc.version', "2")
    writer = jagpdf.create_stream(testlib.NoopStreamOut(), cfg)
    g_font.set_writer(writer)
    do_failures_v2(writer)
    writer.finalize()
Exemplo n.º 30
0
def do_document(argv, name, cfg_opts):
    cfg = testlib.test_config()
    for k, v in cfg_opts.iteritems():
        cfg.set(k, v)
    doc = testlib.create_test_doc(argv, name+'.pdf', cfg)
    doc.page_start(400, 400)
    canvas = doc.page().canvas()
    canvas.text_start(20, 380)
    l = [(k, v) for k, v in cfg_opts.iteritems()]
    l.sort()
    for k, v in l:
        canvas.text("%s : %s" % (k, v))
        canvas.text_translate_line(0, -15)
    canvas.text_end()
    doc.page_end()
    doc.finalize()
Exemplo n.º 31
0
def basic_test(argv):
    lines = ["Jag kan äta glas utan att skada mig.",
             "Rødgrød med mælk og fløde på.",
             "Příliš žluťoučký kůň úpěl ďábelské ódy.",
             "Single encoding."]
    profile = testlib.test_config()
    profile.set("doc.trace_level", "2")
    doc = testlib.create_test_doc(argv, 'adobefont_unicode.pdf', profile)
    fnt = doc.font_load("standard; name=Helvetica; size=12; enc=utf-8")
    doc.page_start(500, 500)
    canvas = doc.page().canvas()
    canvas.text_font(fnt)
    # n texts
    for line, y in zip(lines, [110, 90, 70, 50]):
        canvas.text(50, y, line)
    # single multiline text
    canvas.text_start(50, 150)
    for line in lines:
        canvas.text(line)
        canvas.text_translate_line(0, 15)
    canvas.text_end()
    # all in one line
    fnt_8 = doc.font_load("standard; name=Helvetica; size=8; enc=utf-8")
    canvas.text_font(fnt_8)
    joined = " ".join(lines)
    rect_w = fnt_8.advance(joined)
    # enable the following lines to see BANG
    canvas.state_save()
    canvas.color('s', 0.5)
    canvas.rectangle(10, 250, rect_w, 100)
    canvas.path_paint('s')
    canvas.state_restore()
    canvas.text(10, 300, joined)
    # full justification
    t = unicode(lines[1] + ' ' + lines[2], 'utf-8')
    w = fnt_8.advance(t)
    spaces = [i for i in range(len(t)) if t[i] == u' ']
    nr_spaces = len(spaces)
    padd = -(1000 / fnt_8.size()) * (rect_w - w) / nr_spaces
    positions = [padd for i in range(nr_spaces)]
    canvas.text(10, 320, t, positions, spaces)
    #
    canvas.text(10, 400, "Cyrillic >\xd0\x96\xd1\x86\xd0\xba<")
    #
    check_font_metrics(doc)
    doc.page_end()
    doc.finalize()
Exemplo n.º 32
0
def test_main(argv=None):
    #raw_input('.......')
    if argv==None:
        argv=sys.argv
    out_file = os.path.abspath(os.path.join(argv[1], 'pattern-nonstd-op.pdf'))
    cfg = testlib.test_config()
    doc = jagpdf.create_stream(testlib.FileStreamOut(out_file), cfg)

    patt_canvas = doc.canvas_create()
    testlib.must_throw(doc.tiling_pattern_load,
                       "step=0, 0",
                       patt_canvas) # empty canvas
    patt_canvas.move_to(5, 5)
    patt_canvas.line_to(15, 15)
    patt_canvas.path_paint("fs")
    testlib.must_throw(doc.tiling_pattern_load,
                       "matrix=1, 0, 0, 1, 0, 0",
                       patt_canvas) # no step
    patt_id = doc.tiling_pattern_load("step=20, 20", patt_canvas)

    # use pattern
    doc.page_start(5.9*72, 3.5*72)
    writer = doc.page().canvas()
    writer.color_space_pattern_uncolored("f", jagpdf.CS_DEVICE_GRAY)
    writer.pattern("f", patt_id, .5)
    writer.rectangle(36, 36, 144, 144)
    writer.path_paint("sf")

    #try to write to pattern that is already registered
    patt_canvas.rectangle(7, 7, 6, 6)
    patt_canvas.path_paint("fs")
    writer.rectangle(36+144+4, 36, 144, 144)
    writer.path_paint("sf")

    doc.page_end()

    # !!!! suprising - try to write to pattern that is already outputted
    patt_canvas.circle(10, 10, 5)
    patt_canvas.path_paint("s")

    # !!!! this is wild -> causes abort
    #patt_canvas.paint("fs")

    doc.finalize()
Exemplo n.º 33
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('doc.version', "2")
    cfg.set('fonts.force_cid', "1")

    writer = testlib.create_test_doc(argv, "fonts_in_1_2.pdf", cfg)
    g_font.set_writer(writer)

    writer.page_start(72, 72)
    page = writer.page().canvas()
    page.text_font(g_font())
    page.text(20, 20, "OK")
    page.text(20, 40, "1.2 - OK")

    fspec = os.path.expandvars('enc=ISO_8859-3:1988; size=10; file=${JAG_TEST_RESOURCES_DIR}/fonts/DejaVuSans.ttf')
    testlib.must_throw(writer.font_load, fspec) #no cid fonts embedding allowed in <1.3

    writer.page_end()
    writer.finalize()
Exemplo n.º 34
0
def test_main(argv=None):
    #raw_input('.......')
    if argv == None:
        argv = sys.argv
    out_file = os.path.abspath(os.path.join(argv[1], 'pattern-nonstd-op.pdf'))
    cfg = testlib.test_config()
    doc = jagpdf.create_stream(testlib.FileStreamOut(out_file), cfg)

    patt_canvas = doc.canvas_create()
    testlib.must_throw(doc.tiling_pattern_load, "step=0, 0",
                       patt_canvas)  # empty canvas
    patt_canvas.move_to(5, 5)
    patt_canvas.line_to(15, 15)
    patt_canvas.path_paint("fs")
    testlib.must_throw(doc.tiling_pattern_load, "matrix=1, 0, 0, 1, 0, 0",
                       patt_canvas)  # no step
    patt_id = doc.tiling_pattern_load("step=20, 20", patt_canvas)

    # use pattern
    doc.page_start(5.9 * 72, 3.5 * 72)
    writer = doc.page().canvas()
    writer.color_space_pattern_uncolored("f", jagpdf.CS_DEVICE_GRAY)
    writer.pattern("f", patt_id, .5)
    writer.rectangle(36, 36, 144, 144)
    writer.path_paint("sf")

    #try to write to pattern that is already registered
    patt_canvas.rectangle(7, 7, 6, 6)
    patt_canvas.path_paint("fs")
    writer.rectangle(36 + 144 + 4, 36, 144, 144)
    writer.path_paint("sf")

    doc.page_end()

    # !!!! suprising - try to write to pattern that is already outputted
    patt_canvas.circle(10, 10, 5)
    patt_canvas.path_paint("s")

    # !!!! this is wild -> causes abort
    #patt_canvas.paint("fs")

    doc.finalize()
Exemplo n.º 35
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('doc.version', "2")
    cfg.set('fonts.force_cid', "1")

    writer = testlib.create_test_doc(argv, "fonts_in_1_2.pdf", cfg)
    g_font.set_writer(writer)

    writer.page_start(72, 72)
    page = writer.page().canvas()
    page.text_font(g_font())
    page.text(20, 20, "OK")
    page.text(20, 40, "1.2 - OK")

    fspec = os.path.expandvars(
        'enc=ISO_8859-3:1988; size=10; file=${JAG_TEST_RESOURCES_DIR}/fonts/DejaVuSans.ttf'
    )
    testlib.must_throw(writer.font_load,
                       fspec)  #no cid fonts embedding allowed in <1.3

    writer.page_end()
    writer.finalize()
Exemplo n.º 36
0
def test_main(argv=None):
    cfg = testlib.test_config()
    #    cfg.set("doc.trace_level", "5")
    #    cfg.set("doc.trace_show_loc", "0")

    do_invalid_destinations(argv, cfg, 'docoutline_invalid_dest.pdf')
    do_generic_bookmarks(argv, cfg, 'docoutline_generic.pdf')
    do_document(argv, cfg, 'docoutline.pdf')

    cfg.set("doc.version", "3")
    do_document(argv, cfg, 'docoutline13.pdf')

    cfg.set("doc.version", "4")
    cfg.set("doc.encryption", "standard")
    cfg.set("info.static_producer", "1")
    cfg.set("doc.static_file_id", "1")
    cfg.set("info.creation_date", "0")

    do_document(argv, cfg, 'docoutline_enc.pdf')

    ## fault injection
    fault_injection()
Exemplo n.º 37
0
def test_main(argv=None):
    cfg = testlib.test_config()
#    cfg.set("doc.trace_level", "5")
#    cfg.set("doc.trace_show_loc", "0")

    do_invalid_destinations(argv, cfg, 'docoutline_invalid_dest.pdf')
    do_generic_bookmarks(argv, cfg, 'docoutline_generic.pdf')
    do_document(argv, cfg, 'docoutline.pdf')

    cfg.set("doc.version", "3")
    do_document(argv, cfg, 'docoutline13.pdf')

    cfg.set("doc.version", "4")
    cfg.set("doc.encryption", "standard")
    cfg.set("info.static_producer", "1")
    cfg.set("doc.static_file_id", "1")
    cfg.set("info.creation_date", "0")

    do_document(argv, cfg, 'docoutline_enc.pdf')

## fault injection
    fault_injection()
Exemplo n.º 38
0
def test_main(argv=None):
    profile = testlib.test_config()
    profile.set("text.kerning", "1")
    do_doc(argv, 'kerning2.pdf', profile)
Exemplo n.º 39
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('doc.version', "2")
    doc_writer = testlib.create_test_doc(argv, 'img-jpegicc-1_2.pdf', cfg)
    do(doc_writer)
    doc_writer.finalize()
Exemplo n.º 40
0
def test_main(argv=None):
    profile = testlib.test_config()
    profile.set("text.kerning", "1")
    do_doc(argv, 'kerning2.pdf', profile)
Exemplo n.º 41
0
 def __init__(self, option, value):
     self.profile = testlib.test_config()
     self.profile.set(option, value)
     self.profile.set('info.title', 'The title of this document')
     self.option = option
     self.value = value
Exemplo n.º 42
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('doc.compressed', "1")
    doc_writer = testlib.create_test_doc(argv, 'deflated.pdf', cfg)
    do_basic_page(doc_writer)
    doc_writer.finalize()
Exemplo n.º 43
0
 def __init__(self, option, value):
     self.profile = testlib.test_config()
     self.profile.set(option, value)
     self.profile.set('info.title', 'The title of this document')
     self.option = option
     self.value = value
Exemplo n.º 44
0
def test_main(argv=None):
    profile = testlib.test_config()
    profile.set('doc.topdown', "1")
    do_file(argv, "topdown3.pdf", profile)
Exemplo n.º 45
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('doc.version', "2")
    doc_writer = testlib.create_test_doc(argv, 'img-jpegicc-1_2.pdf', cfg)
    do(doc_writer)
    doc_writer.finalize()
Exemplo n.º 46
0
def test_main(argv=None):
    cfg = testlib.test_config()
    cfg.set('doc.compressed', "1")
    doc_writer = testlib.create_test_doc(argv, 'deflated.pdf', cfg)
    do_basic_page(doc_writer)
    doc_writer.finalize()