Spaces:
Sleeping
Sleeping
File size: 512 Bytes
ad5ca2c |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import subprocess
def get_pdf_page_count(pdf_path):
try:
# Running pdfinfo command to get information about the PDF
result = subprocess.run(['pdfinfo', pdf_path], stdout=subprocess.PIPE, text=True)
# Parsing the output to find the line with the number of pages
for line in result.stdout.split('\n'):
if 'Pages:' in line:
return int(line.split(':')[1].strip())
except Exception as e:
print(f"An error occurred: {e}")
return None |