initial commit

This commit is contained in:
2026-03-23 20:25:30 -05:00
commit dfe04db493
5 changed files with 148 additions and 0 deletions

31
combine_pdfs.py Normal file
View File

@@ -0,0 +1,31 @@
from PyPDF2 import PdfMerger, PdfReader
import os
# Directory containing the invoice PDFs
invoices_dir = "invoices"
# Get all PDF files and sort them
pdf_files = [f for f in os.listdir(invoices_dir) if f.endswith('.pdf')]
pdf_files.sort()
# Create a PDF merger object
merger = PdfMerger()
# Add each PDF to the merger
for pdf_file in pdf_files:
pdf_path = os.path.join(invoices_dir, pdf_file)
# For Audible PDFs, only include the first page
if "Audible" in pdf_file:
merger.append(pdf_path, pages=(0, 1))
print(f"Added (first page only): {pdf_file}")
else:
merger.append(pdf_path)
print(f"Added: {pdf_file}")
# Write the combined PDF
output_path = "receipts.pdf"
merger.write(output_path)
merger.close()
print(f"\nCombined {len(pdf_files)} PDFs into {output_path}")