Edit PDF in Python

High-speed and cross-platform Python library for editing PDF using Python code

Edit PDF using Aspose.Slides

Aspose.Slides for Python via .NET is a powerful Python library used to manipulate and edit presentations, PDF documents, and other files. You can edit an PDF doc by adding a new line of text to it.

Edit PDF in Python

Using Aspose.Slides for Python via .NET , you can add a new line of text to an PDF document with just a few lines of code.

Python code for editing PDF


import aspose.slides as slides

with slides.Presentation() as pres:
    pres.slides.remove_at(0)
    pres.slides.add_from_pdf("document.pdf")

    shape = pres.slides[0].shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 10, 10, 100, 50)
    shape.text_frame.text = "New text"

    pres.save("document.pdf", slides.export.SaveFormat.PDF)

How to edit PDF in Python

  1. Install Aspose.Slides for Python via .NET. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the PDF document you want to edit.

  5. Add a new line of text.

  6. Save the changed PDF file.

Edit other files

You can also edit files in other formats