bool pdf_rotate ( resource pdfdoc, float degrees)
bool pdf_skew ( resource pdfdoc, float alpha, float beta)
We can further manipulate images through the use of pdf_rotate() and pdf_skew() - two functions you should be able to guess quite easily.
As per usual, both pdf_rotate() and pdf_skew() take a PDF document reference as their first parameter. pdf_rotate() then takes one extra parameter - how much to rotate the co-ordinate system by, in degrees - whereas pdf_skew takes two extra parameters - how much to skew the co-ordinate system by in the X direction and how much in the Y direction.
Try adding these two lines just after the call to pdf_begin_page() inside the loop:
pdf_skew($pdf, 10, 10); pdf_rotate($pdf, 5);
Re-save the file and generate the PDF file again. You may need to comment one of the lines out at a time to clearly see what effect each call has on your document, however you should also notice that these two functions allow you to rotate and skew your text as well as your pictures.
Want to learn PHP 7?
Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!
Next chapter: Adding document data >>
Previous chapter: Adding imagery
Home: Table of Contents
Copyright ©2015 Paul Hudson. Follow me: @twostraws.