fpdf.php

来自「php绿色服务器,让大家试用greenamp」· PHP 代码 · 共 2,044 行 · 第 1/5 页

PHP
2,044
字号
                $pal = fread($f, $n);                fread($f, 4);            }            else if ($type == 'tRNS') {                // Reads transparency info                $t            = fread($f, $n);                if ($ct == 0) {                    $trns     = array(ord(substr($t, 1, 1)));                }                else if ($ct == 2) {                    $trns     = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));                }                else {                    $pos      = strpos(' ' . $t, chr(0));                    if ($pos) {                        $trns = array($pos - 1);                    }                    fread($f,4);                } // end if... else if... else            }            else if ($type == 'IDAT') {                // Reads image data block                $data .= fread($f, $n);                fread($f, 4);            }            else if ($type == 'IEND') {                break;            }            else {                fread($f, $n + 4);            } // end if... else if... else        } while ($n); // end do        if ($colspace == 'Indexed' && empty($pal)) {            $this->Error('Missing palette in ' . $file);        }        fclose($f);        return array('w'     => $w,                     'h'     => $h,                     'cs'    => $colspace,                     'bpc'   => $bpc,                     'f'     => 'FlateDecode',                     'parms' => $parms,                     'pal'   => $pal,                     'trns'  => $trns,                     'data'  => $data);    } // end of the "_parsepng()" method    /**************************************************************************    *                                                                         *    *                             Public methods                              *    *                                                                         *    **************************************************************************/    /**     * Sets auto page break mode and triggering margin     *     * @param  string  The auto page break mode     * @param  double  Maximum size till the bottom of the page to start adding     *                 page break     *     * @access public     */    function SetAutoPageBreak($auto, $margin = 0)    {        $this->AutoPageBreak    = $auto;        $this->bMargin          = $margin;        $this->PageBreakTrigger = $this->h - $margin;    } // end of the "SetAutoPageBreak()" method    /**     * Sets display mode in viewer     *     * @param  mixed   The zoom mode (fullpage, fullwidth, real, default,     *                 zoom or an zoom factor -real-)     * @param  string  The layout mode (single, continuous, two or default)     *     * @access public     */    function SetDisplayMode($zoom = 'default', $layout = 'continuous')    {        if (is_string($zoom)) {            $zoom = strtolower($zoom);        }        $layout   = strtolower($layout);        // Zoom mode        if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default'            || !is_string($zoom)) {            $this->ZoomMode = $zoom;        } else if ($zoom == 'zoom') {            $this->ZoomMode = $layout;        } else {            $this->Error('Incorrect zoom display mode: ' . $zoom);        } // end if... else if... else...        // Layout mode        if ($layout == 'single' || $layout == 'continuous' || $layout=='two' || $layout=='default') {            $this->LayoutMode = $layout;        } else if ($zoom != 'zoom') {            $this->Error('Incorrect layout display mode: ' . $layout);        } // end if... else if...    } // end of the "SetDisplayMode()" method    /**     * Sets page compression     *     * @param  boolean  whether to compress file or not     *     * @access public     */    function SetCompression($compress)    {        if (function_exists('gzcompress')) {            $this->compress = $compress;        } else {            $this->compress = FALSE;        } // end if... else...    } // end of the "SetCompression()" method    /**     * Sets page margins     *     * @param  double  The left margin     * @param  double  The top margin     * @param  double  The right margin     *     * @access public     */    function SetMargins($left, $top, $right = -1)    {        $this->lMargin = $left;        $this->tMargin = $top;        if ($right == -1) {            $right = $left;        }        $this->rMargin = $right;    } // end of the "SetMargins()" method    /**     * The FPDF constructor     *     * @param  string  The page orientation (p, portrait, l or landscape)     * @param  string  The unit for sizes (pt, mm, cm or in)     * @param  mixed   The page format (A3, A4, A5, letter, legal or an array     *                 with page sizes)     *     * @access public     */    function FPDF($orientation = 'P', $unit = 'mm', $format = 'A4')    {        // Check for PHP locale-related bug        if (1.1 == 1) {            $this->Error('Don\'t call setlocale() before including class file');        }        // Initialization of properties        $this->page               = 0;        $this->n                  = 2;        $this->buffer             = '';        $this->pages              = array();        $this->OrientationChanges = array();        $this->state              = 0;        $this->fonts              = array();        $this->FontFiles          = array();        $this->diffs              = array();        $this->images             = array();        $this->links              = array();        $this->InFooter           = FALSE;        $this->FontFamily         = '';        $this->FontStyle          = '';        $this->FontSizePt         = 12;        $this->underline          = FALSE;        $this->DrawColor          = '0 G';        $this->FillColor          = '0 g';        $this->TextColor          = '0 g';        $this->ColorFlag          = FALSE;        $this->ws                 = 0;        // Standard fonts        $this->CoreFonts['courier']      = 'Courier';        $this->CoreFonts['courierB']     = 'Courier-Bold';        $this->CoreFonts['courierI']     = 'Courier-Oblique';        $this->CoreFonts['courierBI']    = 'Courier-BoldOblique';        $this->CoreFonts['helvetica']    = 'Helvetica';        $this->CoreFonts['helveticaB']   = 'Helvetica-Bold';        $this->CoreFonts['helveticaI']   = 'Helvetica-Oblique';        $this->CoreFonts['helveticaBI']  = 'Helvetica-BoldOblique';        $this->CoreFonts['times']        = 'Times-Roman';        $this->CoreFonts['timesB']       = 'Times-Bold';        $this->CoreFonts['timesI']       = 'Times-Italic';        $this->CoreFonts['timesBI']      = 'Times-BoldItalic';        $this->CoreFonts['symbol']       = 'Symbol';        $this->CoreFonts['zapfdingbats'] = 'ZapfDingbats';        // Scale factor        if ($unit == 'pt') {            $this->k = 1;        } else if ($unit == 'mm') {            $this->k = 72/25.4;        } else if ($unit == 'cm') {            $this->k = 72/2.54;        } else if ($unit == 'in') {            $this->k = 72;        } else {            $this->Error('Incorrect unit: ' . $unit);        } // end if... else if... else...        // Page format        if (is_string($format)) {            // 2002-07-24 - Nicola Asuni (info@tecnick.com)            // Added new page formats (45 standard ISO paper formats and 4            // american common formats).            // Paper cordinates are calculated in this way:            //    (inches * 72) where (1 inch = 2.54 cm)            switch (strtoupper($format)) {                case '4A0':                    $format = array(4767.87, 6740.79);                    break;                case '2A0':                    $format = array(3370.39, 4767.87);                    break;                case 'A0':                    $format = array(2383.94, 3370.39);                    break;                case 'A1':                    $format = array(1683.78, 2383.94);                    break;                case 'A2':                    $format = array(1190.55, 1683.78);                    break;                case 'A3':                    $format = array(841.89, 1190.55);                    break;                case 'A4':                    $format = array(595.28, 841.89);                    break;                case 'A5':                    $format = array(419.53, 595.28);                    break;                case 'A6':                    $format = array(297.64, 419.53);                    break;                case 'A7':                    $format = array(209.76, 297.64);                    break;                case 'A8':                    $format = array(147.40, 209.76);                    break;                case 'A9':                    $format = array(104.88, 147.40);                    break;                case 'A10':                    $format = array(73.70, 104.88);                    break;                case 'B0':                    $format = array(2834.65, 4008.19);                    break;                case 'B1':                    $format = array(2004.09, 2834.65);                    break;                case 'B2':                    $format = array(1417.32, 2004.09);                    break;                case 'B3':                    $format = array(1000.63, 1417.32);                    break;                case 'B4':                    $format = array(708.66, 1000.63);                    break;                case 'B5':                    $format = array(498.90, 708.66);                    break;                case 'B6':                    $format = array(354.33, 498.90);                    break;                case 'B7':                    $format = array(249.45, 354.33);                    break;                case 'B8':                    $format = array(175.75, 249.45);                    break;                case 'B9':                    $format = array(124.72, 175.75);                    break;                case 'B10':                    $format = array(87.87, 124.72);                    break;                case 'C0':                    $format = array(2599.37, 3676.54);                    break;                case 'C1':                    $format = array(1836.85, 2599.37);                    break;                case 'C2':                    $format = array(1298.27, 1836.85);                    break;                case 'C3':                    $format = array(918.43, 1298.27);                    break;                case 'C4':                    $format = array(649.13, 918.43);                    break;                case 'C5':                    $format = array(459.21, 649.13);                    break;                case 'C6':                    $format = array(323.15, 459.21);                    break;                case 'C7':                    $format = array(229.61, 323.15);                    break;                case 'C8':                    $format = array(161.57, 229.61);                    break;                case 'C9':                    $format = array(113.39, 161.57);                    break;                case 'C10':                    $format = array(79.37, 113.39);                    break;                case 'RA0':                    $format = array(2437.80, 3458.27);                    break;                case 'RA1':                    $format = array(1729.13, 2437.80);                    break;                case 'RA2':                    $format = array(1218.90, 1729.13);                    break;                case 'RA3':                    $format = array(864.57, 1218.90);                    break;                case 'RA4':                    $format = array(609.45, 864.57);                    break;                case 'SRA0':                    $format = array(2551.18, 3628.35);                    break;                case 'SRA1':                    $format = array(1814.17, 2551.18);                    break;                case 'SRA2':                    $format = array(1275.59, 1814.17);                    break;                case 'SRA3':                    $format = array(907.09, 1275.59);                    break;                case 'SRA4':                    $format = array(637.80, 907.09);                    break;                case 'LETTER':                    $format = array(612.00, 792.00);                    break;                case 'LEGAL':                    $format = array(612.00, 1008.00);                    break;                case 'EXECUTIVE':                    $format = array(521.86, 756.00);                    break;                case 'FOLIO':                    $format = array(612.00, 936.00);                    break;                default:                    $this->Error('Unknown page format: ' . $format);                    break;            } // end switch            $this->fwPt = $format[0];            $this->fhPt = $format[1];        }        else {            $this->fwPt = $format[0] * $this->k;            $this->fhPt = $format[1] * $this->k;        } // end if... else...        $this->fw       = $this->fwPt / $this->k;        $this->fh       = $this->fhPt / $this->k;        // Page orientation        $orientation    = strtolower($orientation);        if ($orientation == 'p' || $orientation == 'portrait') {            $this->DefOrientation = 'P';            $this->wPt            = $this->fwPt;            $this->hPt            = $this->fhPt;        }        else if ($orientation == 'l' || $orientation == 'landscape') {            $this->DefOrientation = 'L';            $this->wPt            = $this->fhPt;            $this->hPt            = $this->fwPt;        }        else {            $this->Error('Incorrect orientation: ' . $orientation);        } // end if... else if... else...        $this->CurOrientation     = $this->DefOrientation;        $this->w                  = $this->wPt / $this->k;        $this->h                  = $this->hPt / $this->k;        // Page margins (1 cm)        $margin          = 28.35 / $this->k;        $this->SetMargins($margin, $margin);        // Interior cell margin (1 mm)        $this->cMargin   = $margin / 10;

⌨️ 快捷键说明

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