本文整理汇总了PHP中Zend_Pdf_Page::rotate方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Page::rotate方法的具体用法?PHP Zend_Pdf_Page::rotate怎么用?PHP Zend_Pdf_Page::rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf_Page
的用法示例。
在下文中一共展示了Zend_Pdf_Page::rotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawFont
protected function drawFont($object)
{
$fontItem = $object->getItem();
if ($fontItem->getFace() == 'bold') {
$fontDecoration = 'bold';
} else {
$fontDecoration = 'regular';
}
$fontPath = SERVER_BASE . '/fonts/' . $fontItem->getName() . '.ttf';
if (is_file($fontPath)) {
$font = Zend_Pdf_Font::fontWithPath($fontPath, Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION);
} else {
if ($fontDecoration == "bold") {
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
} else {
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
}
}
if ($fontItem->getFace() == "invert") {
$this->page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
//schwarze farbe setzen fuer Hintergrund
$width = $this->widthForStringUsingFontSize($object->getValue(), $font, $fontItem->getSize());
$height = $fontItem->getSize();
$this->page->drawRectangle($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())) + $height / 2, $this->coordX($this->mmToPts($object->getPosx())) + $width, $this->coordY($this->mmToPts($object->getPosy())) - $height / 2, Zend_Pdf_Page::SHAPE_DRAW_FILL);
$this->page->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 1));
//weiße farbe setzen fuer Text
} else {
$this->page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
//schwarze farbe setzen fuer text
}
$this->page->setFont($font, $fontItem->getSize());
if ($fontItem->getRotation() !== null) {
$this->page->rotate($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())), deg2rad(360 - $fontItem->getRotation()));
}
$this->page->drawText($object->getValue(), $this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy()) + $fontItem->getSize() / 2), 'UTF-8');
if ($fontItem->getRotation() !== null) {
$this->page->rotate($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())), -deg2rad(360 - $fontItem->getRotation()));
}
}
示例2: testPageCloning
public function testPageCloning()
{
$pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf');
$srcPageCount = count($pdf->pages);
try {
$newPage = clone reset($pdf->pages);
} catch (Zend_Pdf_Exception $e) {
if (strpos($e->getMessage(), 'Cloning Zend_Pdf_Page object using \'clone\' keyword is not supported.') !== 0) {
throw $e;
}
// Exception is thrown
}
$outputPageSet = array();
foreach ($pdf->pages as $srcPage) {
$page = new Zend_Pdf_Page($srcPage);
$outputPageSet[] = $srcPage;
$outputPageSet[] = $page;
$page->saveGS();
// Create new Style
$page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.2))->setLineWidth(3)->setLineDashingPattern(array(3, 2, 3, 4), 1.6)->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);
$page->rotate(0, 0, M_PI_2 / 3);
$page->drawText('Modified by Zend Framework!', 150, 0);
$page->restoreGS();
}
// Add new page generated by Zend_Pdf object (page is attached to the specified the document)
$pdf->pages = $outputPageSet;
$pdf->save(dirname(__FILE__) . '/_files/output.pdf');
unset($pdf);
$pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
$this->assertTrue($pdf1 instanceof Zend_Pdf);
$this->assertEquals($srcPageCount * 2, count($pdf1->pages));
unset($pdf1);
unlink(dirname(__FILE__) . '/_files/output.pdf');
}
示例3: stampOnePage
/**
* Apply stamp on one page with given style.
*
* @param Zend_Pdf_Page $page
* @param Zend_Pdf_Style $style
* @param String $stamp
*
* @return void
*/
protected function stampOnePage($page, $style, $stamp)
{
$height = $page->getHeight();
$page->setStyle($style);
$page->drawRectangle(40, 40, 60, $height - 40, Zend_Pdf_Page::SHAPE_DRAW_STROKE);
$page->rotate(20, 20, 1.57);
$page->drawText($stamp, 50, -10);
}