zmbfeng's picture
slide show implemented
ad5ca2c
raw
history blame
512 Bytes
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