From: Antonio Ospite <ao2@ao2.it>
Date: Wed, 22 Sep 2021 20:17:12 +0000 (+0200)
Subject: pdfstrip.py: skip empty pages
X-Git-Url: https://git.ao2.it/pdfstrip.git/commitdiff_plain/b0176c6f974df87c6980461dbbd00af0dd9166b0?hp=2b52f12cb0ebea46a246c03955df476a4dc26a3a

pdfstrip.py: skip empty pages

Skip empty pages and keep going, this fixes processing some PDF files
that have placeholder pages.
---

diff --git a/pdfstrip.py b/pdfstrip.py
index 006eefc..dd212ff 100755
--- a/pdfstrip.py
+++ b/pdfstrip.py
@@ -38,6 +38,10 @@ def strip_objects(pdf, objects_ids):
     for i, page in enumerate(pdf.pages):
         logger.debug("Page %d", i + 1)
 
+        # skip empty pages
+        if not page.Resources.XObject:
+            continue
+
         # Map all the objects in the page using the objects id as the key and
         # the resource name as the value.
         name_map = {indirect_obj.indirect[0]: name for name, indirect_obj in page.Resources.XObject.items()}