예제 #1
0
def test_bookmark_write_to_stream():
    stream = BytesIO()
    bm = Bookmark(NameObject("title"), NullObject(), NameObject(TF.FIT_V),
                  FloatObject(0))
    bm.write_to_stream(stream, None)
    stream.seek(0, 0)
    assert stream.read() == b"<<\n/Title title\n/Dest [ null /FitV 0 ]\n>>"
예제 #2
0
def test_destination_fit_r():
    d = Destination(
        NameObject("title"),
        NullObject(),
        NameObject(TF.FIT_R),
        FloatObject(0),
        FloatObject(0),
        FloatObject(0),
        FloatObject(0),
    )
    assert d.title == NameObject("title")
    assert d.typ == "/FitR"
    assert d.zoom is None
    assert d.left == FloatObject(0)
    assert d.right == FloatObject(0)
    assert d.top == FloatObject(0)
    assert d.bottom == FloatObject(0)
    assert list(d) == []
    d.empty_tree()
예제 #3
0
def test_destination_exception():
    with pytest.raises(PdfReadError):
        Destination(NameObject("title"), NullObject(), NameObject("foo"),
                    FloatObject(0))
예제 #4
0
def test_destination_fit_v():
    Destination(NameObject("title"), NullObject(), NameObject(TF.FIT_V),
                FloatObject(0))
예제 #5
0
def test_null_object_exception():
    stream = BytesIO(b"notnull")
    with pytest.raises(PdfReadError) as exc:
        NullObject.read_from_stream(stream)
    assert exc.value.args[0] == "Could not read Null object"
예제 #6
0
 def _sweepIndirectReferences(self, externMap, data):
     try:
         return super(TolerantPdfWriter,
                      self)._sweepIndirectReferences(externMap, data)
     except PdfReadError:
         return NullObject()