Exemplo n.º 1
0
def test_simple_text_stamp(tmp_path):
    outfile: Path = tmp_path / "test-out.pdf"
    text_stamp_file(MINIMAL_PATH,
                    str(outfile),
                    TextStampStyle(stamp_text="Hi, it's\n%(ts)s"),
                    dest_page=0,
                    x=70,
                    y=50)
Exemplo n.º 2
0
def test_simple_text_stamp_missing_params(tmp_path):
    outfile: Path = tmp_path / "test-out.pdf"
    msg = "Stamp text parameter 'foo' is missing"
    with pytest.raises(LayoutError, match=msg):
        text_stamp_file(MINIMAL_PATH,
                        str(outfile),
                        TextStampStyle(stamp_text="%(foo)s missing"),
                        dest_page=0,
                        x=70,
                        y=50)
Exemplo n.º 3
0
def stamp(ctx, infile, outfile, x, y, style_name, page, stamp_url):
    with pyhanko_exception_manager():
        stamp_style = _select_style(ctx, style_name, stamp_url)
        page_ix = _index_page(page)
        if stamp_url:
            qr_stamp_file(infile,
                          outfile,
                          stamp_style,
                          dest_page=page_ix,
                          x=x,
                          y=y,
                          url=stamp_url)
        else:
            text_stamp_file(infile,
                            outfile,
                            stamp_style,
                            dest_page=page_ix,
                            x=x,
                            y=y)