Edit PDF in PHP
Import PDF pages, add presentation elements, and export the result to PDF with Aspose.Slides for PHP via Java.
Edit PDF using Aspose.Slides
Aspose.Slides for PHP via Java can import PDF pages into a presentation, let you add or modify presentation elements, and export the result as a new PDF document.
This workflow does not edit the source PDF in place. The following example imports a PDF, adds a rectangle containing text to the first imported page, and saves the result as a new PDF file.
Edit PDF in PHP
Using Aspose.Slides for PHP via Java , you can import PDF pages, add a text shape to the first generated slide, and export the modified content to PDF with a few lines of PHP code.
PHP code for editing PDF
$presentation = new Presentation();
try {
$presentation->getSlides()->removeAt(0);
$presentation->getSlides()->addFromPdf("input.pdf");
$slide = $presentation->getSlides()->get_Item(0);
$shape = $slide->getShapes()->addAutoShape(
ShapeType::Rectangle, 10, 10, 100, 50);
$shape->getTextFrame()->setText("New text");
$presentation->save("output.pdf", SaveFormat::Pdf);
} finally {
$presentation->dispose();
}
How to edit PDF in PHP
Install Aspose.Slides for PHP via Java. See Installation .
Configure Aspose.Slides in your PHP project.
Create a
Presentationand remove its default slide withremoveAt(0).Import the PDF pages with
addFromPdf.Access the first imported slide, add a rectangle with
addAutoShape, and set its text withsetText.Call
savewith the output file path andSaveFormat::Pdf.