diff --git a/tests/pdfs/issue-297-example.pdf b/tests/pdfs/issue-297-example.pdf new file mode 100644 index 0000000..b3a60b2 --- /dev/null +++ b/tests/pdfs/issue-297-example.pdf @@ -0,0 +1,47 @@ +%PDF-1.3 +1 0 obj +<< +/Type /Pages +/Count 1 +/Kids [ 3 0 R ] +>> +endobj +2 0 obj +<< +/Producer (PyPDF2) +/Title (IntMetadata) +%%Postscript (OFF) +/Copies 0 +>> +endobj +3 0 obj +<< +/Type /Page +/Parent 1 0 R +/Resources << +>> +/MediaBox [ 0 0 612 792 ] +>> +endobj +4 0 obj +<< +/Type /Catalog +/Pages 1 0 R +>> +endobj +xref +0 5 +0000000000 65535 f +0000000009 00000 n +0000000068 00000 n +0000000160 00000 n +0000000250 00000 n +trailer +<< +/Size 5 +/Root 4 0 R +/Info 2 0 R +>> +startxref +299 +%%EOF diff --git a/tests/test_issues.py b/tests/test_issues.py index d278482..198e338 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -160,3 +160,11 @@ class Test(unittest.TestCase): with pdfplumber.open(path) as pdf: cropped = pdf.pages[0].crop((0, 0, 1, 1)) assert cropped.extract_table() is None + + def test_issue_297(self): + """ + Handle integer type metadata + """ + path = os.path.join(HERE, "pdfs/issue-297-example.pdf") + with pdfplumber.open(path) as pdf: + assert isinstance(pdf.metadata["Copies"], int)