2021-08-29 19:32:14 +00:00
|
|
|
from nose.tools import assert_equal, raises
|
2019-10-25 20:49:58 +00:00
|
|
|
|
2019-10-26 16:42:33 +00:00
|
|
|
from helpers import absolute_sample_path
|
2019-10-25 20:49:58 +00:00
|
|
|
from pdfminer.pdfdocument import PDFDocument
|
|
|
|
from pdfminer.pdfparser import PDFParser
|
2019-10-26 16:42:33 +00:00
|
|
|
from pdfminer.pdftypes import PDFObjectNotFound
|
2019-10-25 20:49:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestPdfDocument(object):
|
|
|
|
|
|
|
|
@raises(PDFObjectNotFound)
|
|
|
|
def test_get_zero_objid_raises_pdfobjectnotfound(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
with open(absolute_sample_path('simple1.pdf'), 'rb') as in_file:
|
2019-10-25 20:49:58 +00:00
|
|
|
parser = PDFParser(in_file)
|
|
|
|
doc = PDFDocument(parser)
|
2019-10-26 16:42:33 +00:00
|
|
|
doc.getobj(0)
|
2021-08-29 19:32:14 +00:00
|
|
|
|
|
|
|
def test_encrypted_no_id(self):
|
|
|
|
# Some documents may be encrypted but not have an /ID key in
|
|
|
|
# their trailer. Tests
|
|
|
|
# https://github.com/pdfminer/pdfminer.six/issues/594
|
|
|
|
path = absolute_sample_path('encryption/encrypted_doc_no_id.pdf')
|
|
|
|
with open(path, 'rb') as fp:
|
|
|
|
parser = PDFParser(fp)
|
|
|
|
doc = PDFDocument(parser)
|
|
|
|
assert_equal(doc.info,
|
|
|
|
[{'Producer': b'European Patent Office'}])
|