aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2022-07-26 10:05:46 +0200
committerJ08nY2022-07-26 10:06:22 +0200
commit63e986b66e8578836d587bd91c17ed1aa70e15fe (patch)
tree49cb1d3e7aff39347a432bf674a5a63e182a9f4b
parent5bb98186b9126f2cadc5f8996e27ba437086dd9a (diff)
downloadsec-certs-63e986b66e8578836d587bd91c17ed1aa70e15fe.tar.gz
sec-certs-63e986b66e8578836d587bd91c17ed1aa70e15fe.tar.zst
sec-certs-63e986b66e8578836d587bd91c17ed1aa70e15fe.zip
Ignore errors in hyperlink collection from PDFs.
-rw-r--r--sec_certs/utils/pdf.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/sec_certs/utils/pdf.py b/sec_certs/utils/pdf.py
index 0f272d1b..9b55d370 100644
--- a/sec_certs/utils/pdf.py
+++ b/sec_certs/utils/pdf.py
@@ -195,13 +195,16 @@ def extract_pdf_metadata(filepath: Path) -> Tuple[str, Optional[Dict[str, Any]]]
annots = reduce(lambda x, y: x + y, annots)
links = set()
for a in annots:
- if isinstance(a, IndirectObject):
- note = a.getObject()
- else:
- note = a
- link = note.get("/A", {}).get("/URI")
- if link:
- links.add(map_metadata_value(link))
+ try:
+ if isinstance(a, IndirectObject):
+ note = a.getObject()
+ else:
+ note = a
+ link = note.get("/A", {}).get("/URI")
+ if link:
+ links.add(map_metadata_value(link))
+ except Exception:
+ pass
metadata["pdf_hyperlinks"] = links
except Exception as e: