python ile yapabilirsiniz. bilginiz yoksa pdf iletin yapıp iletiyim.
from PyPDF2 import PdfReader, PdfWriter
# Input PDF file
input_pdf = "File.pdf"
# Output PDF files
a3_pdf = "A3_pages.pdf"
a4_pdf = "A4_pages.pdf"
# A3 and A4 standard sizes in points
MM_TO_PT = 2.83465
A4_WIDTH = 210 * MM_TO_PT
A4_HEIGHT = 297 * MM_TO_PT
A3_WIDTH = 297 * MM_TO_PT
A3_HEIGHT = 420 * MM_TO_PT
# Tolerance in points to account for scanned or resized pages
TOLERANCE = 100 # increase if needed
# Open PDF
reader = PdfReader(input_pdf)
a3_writer = PdfWriter()
a4_writer = PdfWriter()
# Iterate through pages
for i, page in enumerate(reader.pages):
width = float(page.mediabox.width)
height = float(page.mediabox.height)
# Use approximate size matching with tolerance
if ((abs(width - A4_WIDTH) < TOLERANCE and abs(height - A4_HEIGHT) < TOLERANCE) or
(abs(width - A4_HEIGHT) < TOLERANCE and abs(height - A4_WIDTH) < TOLERANCE)):
a4_writer.add_page(page)
print(f"Page {i+1} -> A4")
elif ((abs(width - A3_WIDTH) < TOLERANCE and abs(height - A3_HEIGHT) < TOLERANCE) or
(abs(width - A3_HEIGHT) < TOLERANCE and abs(height - A3_WIDTH) < TOLERANCE)):
a3_writer.add_page(page)
print(f"Page {i+1} -> A3")
# Fallback for unusual sizes
elif width > height:
a3_writer.add_page(page)
print(f"Page {i+1} -> A3 (approximate)")
else:
a4_writer.add_page(page)
print(f"Page {i+1} -> A4 (approximate)")
# Save new PDFs
with open(a3_pdf, "wb") as f:
a3_writer.write(f)
with open(a4_pdf, "wb") as f:
a4_writer.write(f)
print("PDF separation complete!")Mantıklı mı hocam bu kod. Sıkıntısız ayırdı.
Mesela bunun ölçüsünü bulamayınca A4 olarak algılamış ayıramamış gibi.