William Entriken
William Entriken

Reputation: 39263

PHP5 open an existing PDF file?

Is it possible to use PHP5 PDF built-in features to edit an existing file, similar to this approach with Zend.

<?php
require_once 'Zend/Pdf.php';

$pdf = Zend_Pdf::load('blank.pdf');
$page = $pdf->pages[0];
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$page->setFont($font, 12);
$page->drawText('Hello world!', 72, 720);
$pdf->save('zend.pdf');
?>

... but without using Zend?

(related to question PDF Editing in PHP?)

Upvotes: 0

Views: 461

Answers (1)

S&#233;bastien Renauld
S&#233;bastien Renauld

Reputation: 19662

There is no such thing as "built in PHP PDF", as the PHP pdflib wrappers are from PECL (and therefore not standard). However, if you'd like to run with pdflib... Have a read of the basic examples here. It isn't much harder than Zend, though slightly less intuitive (and probably less documented).

There are also a couple of PHP userland libraries (PHPPDF and similar) which might provide more features, at a cost: slower processing.

(To install pdflib: pecl install pdflib and then add it to extensions in your php.ini)

Upvotes: 2

Related Questions