How to rotate text while creating PDF in Zend Framework?

守給你的承諾、 提交于 2019-12-24 15:45:25

问题


I am placing text on pdf something like this using Zend_Pdf:

$page1->drawText( 'Hello World!', 100, 100 );

But now I want to rotate text to 90 degree on pdf. How is it possible ??

Thanks


回答1:


How about:
$page->rotate(0, 0, M_PI/12);
$page->drawText('Hello world!', 100, 100);
See also: Zend PDF tutorial




回答2:


You can use rotate() which uses Radians to determine the amount to rotate.

For example:

    // Rotate at the X and Y coordinates 
    // and 90 Degrees Counter-Clockwise (which is 1.5708 Radians)
    $page->rotate(300, 300, 1.5708);

Use this tool calculate the value from degrees. Whilst you can use the constants in PHP and divide (as the other answer suggests) I would not recommend that personally (as I find it much harder to work out what it equates to).

You do need to rotate back before continuing with the next lines (assuming you want them to be horizontal).



来源:https://stackoverflow.com/questions/4363460/how-to-rotate-text-while-creating-pdf-in-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!