pdf (encrypted) to pdf text ; google drive, download as txt. edit
worked on 9th july 2026
pdf (encrypted) to pdf text ; google drive, download as txt. edit
run1
run2 in colab
--------------------
!pip -q install pymupdf Pillow
----------
import fitz
from PIL import Image
import os
input_pdf = "/content/input.pdf"
output_pdf = "/content/output.pdf"
image_dir = "/content/pdf_images"
os.makedirs(image_dir, exist_ok=True)
doc = fitz.open(input_pdf)
images = []
for i, page in enumerate(doc):
pix = page.get_pixmap(dpi=200)
img_path = f"{image_dir}/page_{i+1}.jpg"
pix.save(img_path)
images.append(Image.open(img_path).convert("RGB"))
doc.close()
images[0].save(
output_pdf,
save_all=True,
append_images=images[1:]
)
print("Finished.")
print(output_pdf)
----------------