PyPdfOps is a Python library that simplifies the manipulation of PDF files. It provides a set of methods for common PDF operations, including compression, conversion to different formats (pptx, images, doc), splitting, and merging. With PyPdfOps, you can streamline your PDF-related tasks in your Python projects.
pip install pypdfops
For compressing pdf, PDFNet sdk is used and a token is required to use the compressing feature. To obtain a demo token, head to 'https://dev.apryse.com/get-key', after signin, choose web and get the trial key.
from pypdfops import PDFOps
input_pdf = "input.pdf"
output_pdf = "compressed_output.pdf"
pdf = PDFOps(token = "COMPRESSION_TOKEN") # Token for compression
pdf.compress_pdf(input_pdf, output_pdf)
from pypdfops import PDFOps
input_pdf = "input.pdf"
output_pptx = "converted_pdf.pptx"
pdf = PDFOps()
pdf.convert_to_pptx(input_pdf, output_pptx)
from pypdfops import PDFOps
input_pdf = "input.pdf"
output_folder = "Images"
pdf = PDFOps()
pdf.extract_pages_as_images(input_pdf, output_folder)
from pypdfops import PDFOps
input_pdf = "input.pdf"
output_doc = "converted_pdf.doc"
pdf = PDFOps()
pdf.convert_to_doc(input_pdf, output_doc)
from pypdfops import PDFOps
input_pdf = "input.pdf"
output_folder = "SplittedPdfs"
pages_to_split = [[1,2],[3,5]]
pdf = PDFOps()
pdf.split_pdf(input_pdf, output_folder,pages_to_split)
from pypdfops import PDFOps
input_pdfs = [
"input1.pdf",
"input2.pdf",
"input3.pdf"
]
output_pdf = "Merged.pdf"
pdf = PDFOps()
pdf.merge_pdfs(input_pdfs, output_pdf)
from pypdfops import PDFOps
input_pdf = "input.pdf
output_pdf = "encrypted.pdf"
password = "12345678"
pdf = PDFOps()
pdf.encrypt_pdf(input_pdf, output_pdf, password)
from pypdfops import PDFOps
input_pdf = "input.pdf
output_pdf = "decrypted.pdf"
password = "12345678"
pdf = PDFOps()
pdf.decrypt_pdf(input_pdf, output_pdf, password)
Feel free to customize the examples and add more details to suit your specific use cases.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.