colab pyton code to split pdf into two files.
some time pdf file is not printed due restrictions,
use pyton code, it worked.
help from vertex.
# to be deleted , worked.
!pip install PyPDF2
from PyPDF2 import PdfReader, PdfWriter
# Paths to the files
pdf_file_path = '/content/Hethuvaadhamu-Prathivaadhamu.pdf'
output_text_file_path1 = '/content/Hethuvaadhamu-Prathivaadhamu_100.pdf'
output_text_file_path2 = '/content/Hethuvaadhamu-Prathivaadhamu_205.pdf'
# Read the input PDF file
reader = PdfReader(pdf_file_path)
# Create two PDF writers for the output files
writer1 = PdfWriter()
writer2 = PdfWriter()
# Split the pages and write them to the respective output files
for page_num in range(len(reader.pages)):
if page_num <= 99:
writer1.add_page(reader.pages[page_num])
elif page_num <= 204:
writer2.add_page(reader.pages[page_num])
# Save the output files
with open(output_text_file_path1, 'wb') as outfile1:
writer1.write(outfile1)
with open(output_text_file_path2, 'wb') as outfile2:
writer2.write(outfile2)
print(f"PDF file split into: {output_text_file_path1} and {output_text_file_path2}")