Exemplo n.º 1
0
def test_read_stream(pdf1):
    pdf = pdf_read.PDF(pdf1)
    loc = pdf.object_lookup[pdf_read.PDFObjectId(4, 0)]
    objs = pdf.object_at(loc)
    assert isinstance(objs[1], pdf_read.PDFStreamIndicator)
    loc = objs[1].location
    obj = pdf.read_stream(loc, 33)
    assert obj.contents.startswith(b"q\n1637")
    assert len(obj.contents) == 33
Exemplo n.º 2
0
def test_read_full_object(pdf1):
    p = pdf_read.PDF(pdf1)
    loc = p.object_lookup[pdf_read.PDFObjectId(5, 0)]
    obj = p.full_object_at(loc)
    assert repr(obj) == "PDFNumeric(33)"

    loc = p.object_lookup[pdf_read.PDFObjectId(4, 0)]
    obj = p.full_object_at(loc)
    assert obj[pdf.PDFName("Length")] == pdf.PDFNumeric(33)
    assert obj.stream_contents.startswith(b"q\n1637")
Exemplo n.º 3
0
def test_read_object_1(pdf1):
    p = pdf_read.PDF(pdf1)
    objs = p.object_at(10)
    assert len(objs) == 1
    assert objs[0][pdf.PDFName("Pages")] == pdf.PDFObjectId(2, 0)
    assert objs[0][pdf.PDFName("Type")] == pdf.PDFName("Catalog")
Exemplo n.º 4
0
def test_object_lookup(pdf1):
    pdf = pdf_read.PDF(pdf1)
    assert pdf.object_lookup[pdf_read.PDFObjectId(1, 0)] == 10
    assert pdf.object_lookup[pdf_read.PDFObjectId(10, 0)] == 309482
Exemplo n.º 5
0
def test_trailer(pdf1):
    p = pdf_read.PDF(pdf1)
    assert p.trailer[pdf.PDFName("Size")] == pdf.PDFNumeric(18)
    assert pdf.PDFName("Info") in p.trailer
    assert pdf.PDFName("Root") in p.trailer
Exemplo n.º 6
0
def test_version(pdf1):
    pdf = pdf_read.PDF(pdf1)
    assert pdf.version == "%PDF-1.3"
Exemplo n.º 7
0
def test_read_object_all1(pdf2):
    pdf = pdf_read.PDF(pdf2)
    for key, location in pdf.object_lookup.items():
        # Sort of cheeky test...
        print(key, location, pdf.object_at(location))