⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 4 页
字号:
        $x = ($x1 + $x2)/2.;        $y = ($y1 + $y2)/2.;        $xC = new Zend_Pdf_Element_Numeric($x);        $yC = new Zend_Pdf_Element_Numeric($y);        if ($startAngle !== null) {            if ($startAngle != 0) { $startAngle = fmod($startAngle, M_PI*2); }            if ($endAngle   != 0) { $endAngle   = fmod($endAngle,   M_PI*2); }            if ($startAngle > $endAngle) {                $endAngle += M_PI*2;            }            $clipPath    = $xC->toString() . ' ' . $yC->toString() . " m\n";            $clipSectors = (int)ceil(($endAngle - $startAngle)/M_PI_4);            $clipRadius  = max($x2 - $x1, $y2 - $y1);            for($count = 0; $count <= $clipSectors; $count++) {                $pAngle = $startAngle + ($endAngle - $startAngle)*$count/(float)$clipSectors;                $pX = new Zend_Pdf_Element_Numeric($x + cos($pAngle)*$clipRadius);                $pY = new Zend_Pdf_Element_Numeric($y + sin($pAngle)*$clipRadius);                $clipPath .= $pX->toString() . ' ' . $pY->toString() . " l\n";            }            $this->_contents .= "q\n" . $clipPath . "h\nW\nn\n";        }        $xLeft  = new Zend_Pdf_Element_Numeric($x1);        $xRight = new Zend_Pdf_Element_Numeric($x2);        $yUp    = new Zend_Pdf_Element_Numeric($y2);        $yDown  = new Zend_Pdf_Element_Numeric($y1);        $xDelta  = 2*(M_SQRT2 - 1)*($x2 - $x1)/3.;        $yDelta  = 2*(M_SQRT2 - 1)*($y2 - $y1)/3.;        $xr = new Zend_Pdf_Element_Numeric($x + $xDelta);        $xl = new Zend_Pdf_Element_Numeric($x - $xDelta);        $yu = new Zend_Pdf_Element_Numeric($y + $yDelta);        $yd = new Zend_Pdf_Element_Numeric($y - $yDelta);        $this->_contents .= $xC->toString() . ' ' . $yUp->toString() . " m\n"                         .  $xr->toString() . ' ' . $yUp->toString() . ' '                         .    $xRight->toString() . ' ' . $yu->toString() . ' '                         .      $xRight->toString() . ' ' . $yC->toString() . " c\n"                         .  $xRight->toString() . ' ' . $yd->toString() . ' '                         .    $xr->toString() . ' ' . $yDown->toString() . ' '                         .      $xC->toString() . ' ' . $yDown->toString() . " c\n"                         .  $xl->toString() . ' ' . $yDown->toString() . ' '                         .    $xLeft->toString() . ' ' . $yd->toString() . ' '                         .      $xLeft->toString() . ' ' . $yC->toString() . " c\n"                         .  $xLeft->toString() . ' ' . $yu->toString() . ' '                         .    $xl->toString() . ' ' . $yUp->toString() . ' '                         .      $xC->toString() . ' ' . $yUp->toString() . " c\n";        switch ($fillType) {            case Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE:                $this->_contents .= " B*\n";                break;            case Zend_Pdf_Page::SHAPE_DRAW_FILL:                $this->_contents .= " f*\n";                break;            case Zend_Pdf_Page::SHAPE_DRAW_STROKE:                $this->_contents .= " S\n";                break;        }        if ($startAngle !== null) {            $this->_contents .= "Q\n";        }    }    /**     * Draw an image at the specified position on the page.     *     * @param Zend_Pdf_Image $image     * @param float $x1     * @param float $y1     * @param float $x2     * @param float $y2     */    public function drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2)    {        $this->_addProcSet('PDF');        $imageName    = $this->_attachResource('XObject', $image);        $imageNameObj = new Zend_Pdf_Element_Name($imageName);        $x1Obj     = new Zend_Pdf_Element_Numeric($x1);        $y1Obj     = new Zend_Pdf_Element_Numeric($y1);        $widthObj  = new Zend_Pdf_Element_Numeric($x2 - $x1);        $heightObj = new Zend_Pdf_Element_Numeric($y2 - $y1);        $this->_contents .= "q\n"                         .  '1 0 0 1 ' . $x1Obj->toString() . ' ' . $y1Obj->toString() . " cm\n"                         .  $widthObj->toString() . ' 0 0 ' . $heightObj->toString() . " 0 0 cm\n"                         .  $imageNameObj->toString() . " Do\n"                         .  "Q\n";    }    /**     * Draw a LayoutBox at the specified position on the page.     *     * @param Zend_Pdf_Element_LayoutBox $box     * @param float $x     * @param float $y     */    public function drawLayoutBox($box, $x, $y)    {    }    /**     * Draw a line from x1,y1 to x2,y2.     *     * @param float $x1     * @param float $y1     * @param float $x2     * @param float $y2     */    public function drawLine($x1, $y1, $x2, $y2)    {        $this->_addProcSet('PDF');        $x1Obj = new Zend_Pdf_Element_Numeric($x1);        $y1Obj = new Zend_Pdf_Element_Numeric($y1);        $x2Obj = new Zend_Pdf_Element_Numeric($x2);        $y2Obj = new Zend_Pdf_Element_Numeric($y2);        $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " m\n"                         .  $x2Obj->toString() . ' ' . $y2Obj->toString() . " l\n S\n";    }    /**     * Draw a polygon.     *     * If $fillType is Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE or     * Zend_Pdf_Page::SHAPE_DRAW_FILL, then polygon is automatically closed.     * See detailed description of these methods in a PDF documentation     * (section 4.4.2 Path painting Operators, Filling)     *     * @param array $x  - array of float (the X co-ordinates of the vertices)     * @param array $y  - array of float (the Y co-ordinates of the vertices)     * @param integer $fillType     * @param integer $fillMethod     */    public function drawPolygon($x, $y,                                $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,                                $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)    {        $this->_addProcSet('PDF');        $firstPoint = true;        foreach ($x as $id => $xVal) {            $xObj = new Zend_Pdf_Element_Numeric($xVal);            $yObj = new Zend_Pdf_Element_Numeric($y[$id]);            if ($firstPoint) {                $path = $xObj->toString() . ' ' . $yObj->toString() . " m\n";                $firstPoint = false;            } else {                $path .= $xObj->toString() . ' ' . $yObj->toString() . " l\n";            }        }        $this->_contents .= $path;        switch ($fillType) {            case Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE:                if ($fillMethod == Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) {                    $this->_contents .= " b\n";                } else {                    // Even-Odd fill method.                    $this->_contents .= " b*\n";                }                break;            case Zend_Pdf_Page::SHAPE_DRAW_FILL:                if ($fillMethod == Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) {                    $this->_contents .= " h\n f\n";                } else {                    // Even-Odd fill method.                    $this->_contents .= " h\n f*\n";                }                break;            case Zend_Pdf_Page::SHAPE_DRAW_STROKE:                $this->_contents .= " S\n";                break;        }    }    /**     * Draw a rectangle.     *     * Fill types:     * Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)     * Zend_Pdf_Page::SHAPE_DRAW_STROKE      - stroke rectangle     * Zend_Pdf_Page::SHAPE_DRAW_FILL        - fill rectangle     *     * @param float $x1     * @param float $y1     * @param float $x2     * @param float $y2     * @param integer $fillType     */    public function drawRectangle($x1, $y1, $x2, $y2, $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)    {        $this->_addProcSet('PDF');        $x1Obj      = new Zend_Pdf_Element_Numeric($x1);        $y1Obj      = new Zend_Pdf_Element_Numeric($y1);        $widthObj   = new Zend_Pdf_Element_Numeric($x2 - $x1);        $height2Obj = new Zend_Pdf_Element_Numeric($y2 - $y1);        $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '                             .  $widthObj->toString() . ' ' . $height2Obj->toString() . " re\n";        switch ($fillType) {            case Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE:                $this->_contents .= " B*\n";                break;            case Zend_Pdf_Page::SHAPE_DRAW_FILL:                $this->_contents .= " f*\n";                break;            case Zend_Pdf_Page::SHAPE_DRAW_STROKE:                $this->_contents .= " S\n";                break;        }    }    /**     * Draw a line of text at the specified position.     *     * @param string $text     * @param float $x     * @param float $y     * @param string $charEncoding (optional) Character encoding of source text.     *   Defaults to current locale.     * @throws Zend_Pdf_Exception     */    public function drawText($text, $x, $y, $charEncoding = '')    {        if ($this->_font === null) {            throw new Zend_Pdf_Exception('Font has not been set');        }        $this->_addProcSet('Text');        $textObj = new Zend_Pdf_Element_String($this->_font->encodeString($text, $charEncoding));        $xObj    = new Zend_Pdf_Element_Numeric($x);        $yObj    = new Zend_Pdf_Element_Numeric($y);        $this->_contents .= "BT\n"                         .  $xObj->toString() . ' ' . $yObj->toString() . " Td\n"                         .  $textObj->toString() . " Tj\n"                         .  "ET\n";    }    /**     * Return the height of this page in points.     *     * @return float     */    public function getHeight()    {        return $this->_pageDictionary->MediaBox->items[3]->value -               $this->_pageDictionary->MediaBox->items[1]->value;    }    /**     * Return the width of this page in points.     *     * @return float     */    public function getWidth()    {        return $this->_pageDictionary->MediaBox->items[2]->value -               $this->_pageDictionary->MediaBox->items[0]->value;    }     /**     * Close the path by drawing a straight line back to it's beginning.     *     * @throws Zend_Pdf_Exception    - if a path hasn't been started with pathMove()     */    public function pathClose()    {    }    /**     * Continue the open path in a straight line to the specified position.     *     * @param float $x  - the X co-ordinate to move to     * @param float $y  - the Y co-ordinate to move to     */    public function pathLine($x, $y)    {    }    /**     * Start a new path at the specified position. If a path has already been started,     * move the cursor without drawing a line.     *     * @param float $x  - the X co-ordinate to move to     * @param float $y  - the Y co-ordinate to move to     */    public function pathMove($x, $y)    {    }    /**     * Write raw PDF commands to the page.     *     * @param string $data     */    public function rawWrite($data)    {    }    /**     * Rotate the page.     *     * @param float $angle     */    public function rotate($x, $y, $angle)    {        $cos  = new Zend_Pdf_Element_Numeric(cos($angle));        $sin  = new Zend_Pdf_Element_Numeric(sin($angle));        $mSin = new Zend_Pdf_Element_Numeric(-$sin->value);        $xObj = new Zend_Pdf_Element_Numeric($x);        $yObj = new Zend_Pdf_Element_Numeric($y);        $mXObj = new Zend_Pdf_Element_Numeric(-$x);        $mYObj = new Zend_Pdf_Element_Numeric(-$y);        $this->_addProcSet('PDF');        $this->_contents .= '1 0 0 1 ' . $xObj->toString() . ' ' . $yObj->toString() . " cm\n"                         . $cos->toString() . ' ' . $sin->toString()                         . ' ' . $mSin->toString() . ' ' . $cos->toString() . " 0 0 cm\n"                         .'1 0 0 1 ' . $mXObj->toString() . ' ' . $mYObj->toString() . " cm\n";    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -