Sebastien
Sebastien

Reputation: 6660

Change orientation of a pdf using zend pdf

I have an existing pdf, and i want to load it, change its orientation and save it. I tried this but it doesn't work :

$pdf = Zend_Pdf::load('mypdf');
$page = $pdf->pages[0];
$page->rotate(0,0,deg2rad(90));
$pdf->save('new.pdf');

Any idea?

Upvotes: 2

Views: 2107

Answers (1)

ByteNudger
ByteNudger

Reputation: 1561

You have to assign the page $page to the PDF document $pdf after you rotated the page:

$page->rotate(0,0,deg2rad(90));
$pdf->pages[0] = $page; // assign the page to the PDF document
$pdf->save('new.pdf');

Be aware that in the above example the old page 1 is overwritten in the $pdf object.

Upvotes: 2

Related Questions