|
发表于 2013-4-12 13:04:33
|
显示全部楼层
<?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
class fpdf
{
public function fpdf( $orientation = "P", $unit = "mm", $format = "A4" )
{
$this->_dochecks( );
$this->page = 0;
$this->n = 2;
$this->buffer = "";
$this->pages = array( );
$this->PageSizes = array( );
$this->state = 0;
$this->fonts = array( );
$this->FontFiles = array( );
$this->diffs = array( );
$this->images = array( );
$this->links = array( );
$this->InHeader = false;
$this->InFooter = false;
$this->lasth = 0;
$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;
$this->CoreFonts = array( "courier" => "Courier", "courierB" => "Courier-Bold", "courierI" => "Courier-Oblique", "courierBI" => "Courier-BoldOblique", "helvetica" => "Helvetica", "helveticaB" => "Helvetica-Bold", "helveticaI" => "Helvetica-Oblique", "helveticaBI" => "Helvetica-BoldOblique", "times" => "Times-Roman", "timesB" => "Times-Bold", "timesI" => "Times-Italic", "timesBI" => "Times-BoldItalic", "symbol" => "Symbol", "zapfdingbats" => "ZapfDingbats" );
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 );
}
$this->PageFormats = array(
"a3" => array( 841.89, 1190.55 ),
"a4" => array( 595.28, 841.89 ),
"a5" => array( 420.94, 595.28 ),
"letter" => array( 612, 792 ),
"legal" => array( 612, 1008 )
);
if ( ( $format ) )
{
$format = $this->_getpageformat( $format );
}
$this->DefPageFormat = $format;
$this->CurPageFormat = $format;
$orientation = ( $orientation );
if ( $orientation == "p" || $orientation == "portrait" )
{
$this->DefOrientation = "P";
$this->w = $this->DefPageFormat[0];
$this->h = $this->DefPageFormat[1];
}
else if ( $orientation == "l" || $orientation == "landscape" )
{
$this->DefOrientation = "L";
$this->w = $this->DefPageFormat[1];
$this->h = $this->DefPageFormat[0];
}
else
{
$this->Error( "Incorrect orientation: ".$orientation );
}
$this->CurOrientation = $this->DefOrientation;
$this->wPt = $this->w * $this->k;
$this->hPt = $this->h * $this->k;
$margin = 28.35 / $this->k;
$this->SetMargins( $margin, $margin );
$this->cMargin = $margin / 10;
$this->LineWidth = 0.567 / $this->k;
$this->SetAutoPageBreak( true, 2 * $margin );
$this->SetDisplayMode( "fullwidth" );
$this->SetCompression( true );
$this->PDFVersion = "1.3";
}
public function setmargins( $left, $top, $right = null )
{
$this->lMargin = $left;
$this->tMargin = $top;
if ( $right === null )
{
$right = $left;
}
$this->rMargin = $right;
}
public function setleftmargin( $margin )
{
$this->lMargin = $margin;
if ( 0 < $this->page && $this->x < $margin )
{
$this->x = $margin;
}
}
public function settopmargin( $margin )
{
$this->tMargin = $margin;
}
public function setrightmargin( $margin )
{
$this->rMargin = $margin;
}
public function setautopagebreak( $auto, $margin = 0 )
{
$this->AutoPageBreak = $auto;
$this->bMargin = $margin;
$this->PageBreakTrigger = $this->h - $margin;
}
public function setdisplaymode( $zoom, $layout = "continuous" )
{
if ( $zoom == "fullpage" || $zoom == "fullwidth" || $zoom == "real" || $zoom == "default" || !( $zoom ) )
{
$this->ZoomMode = $zoom;
}
else
{
$this->Error( "Incorrect zoom display mode: ".$zoom );
}
if ( $layout == "single" || $layout == "continuous" || $layout == "two" || $layout == "default" )
{
$this->LayoutMode = $layout;
}
else
{
$this->Error( "Incorrect layout display mode: ".$layout );
}
}
public function setcompression( $compress )
{
if ( ( "gzcompress" ) )
{
$this->compress = $compress;
}
else
{
$this->compress = false;
}
}
public function settitle( $title, $isUTF8 = false )
{
if ( $isUTF8 )
{
$title = $this->_UTF8toUTF16( $title );
}
$this->title = $title;
}
public function setsubject( $subject, $isUTF8 = false )
{
if ( $isUTF8 )
{
$subject = $this->_UTF8toUTF16( $subject );
}
$this->subject = $subject;
}
public function setauthor( $author, $isUTF8 = false )
{
if ( $isUTF8 )
{
$author = $this->_UTF8toUTF16( $author );
}
$this->author = $author;
}
public function setkeywords( $keywords, $isUTF8 = false )
{
if ( $isUTF8 )
{
$keywords = $this->_UTF8toUTF16( $keywords );
}
$this->keywords = $keywords;
}
public function setcreator( $creator, $isUTF8 = false )
{
if ( $isUTF8 )
{
$creator = $this->_UTF8toUTF16( $creator );
}
$this->creator = $creator;
}
public function aliasnbpages( $alias = "{nb}" )
{
$this->AliasNbPages = $alias;
}
public function error( $msg )
{
exit( "<b>FPDF error:</b> ".$msg );
}
public function open( )
{
$this->state = 1;
}
public function close( )
{
if ( $this->state == 3 )
{
return;
}
if ( $this->page == 0 )
{
$this->AddPage( );
}
$this->InFooter = true;
$this->Footer( );
$this->InFooter = false;
$this->_endpage( );
$this->_enddoc( );
}
public function addpage( $orientation = "", $format = "" )
{
if ( $this->state == 0 )
{
$this->Open( );
}
$family = $this->FontFamily;
$style = $this->FontStyle.( $this->underline ? "U" : "" );
$size = $this->FontSizePt;
$lw = $this->LineWidth;
$dc = $this->DrawColor;
$fc = $this->FillColor;
$tc = $this->TextColor;
$cf = $this->ColorFlag;
if ( 0 < $this->page )
{
$this->InFooter = true;
$this->Footer( );
$this->InFooter = false;
$this->_endpage( );
}
$this->_beginpage( $orientation, $format );
$this->_out( "2 J" );
$this->LineWidth = $lw;
$this->_out( ( "%.2F w", $lw * $this->k ) );
if ( $family )
{
$this->SetFont( $family, $style, $size );
}
$this->DrawColor = $dc;
if ( $dc != "0 G" )
{
$this->_out( $dc );
}
$this->FillColor = $fc;
if ( $fc != "0 g" )
{
$this->_out( $fc );
}
$this->TextColor = $tc;
$this->ColorFlag = $cf;
$this->InHeader = true;
$this->Header( );
$this->InHeader = false;
if ( $this->LineWidth != $lw )
{
$this->LineWidth = $lw;
$this->_out( ( "%.2F w", $lw * $this->k ) );
}
if ( $family )
{
$this->SetFont( $family, $style, $size );
}
if ( $this->DrawColor != $dc )
{
$this->DrawColor = $dc;
$this->_out( $dc );
}
if ( $this->FillColor != $fc )
{
$this->FillColor = $fc;
$this->_out( $fc );
}
$this->TextColor = $tc;
$this->ColorFlag = $cf;
}
public function header( )
{
}
public function footer( )
{
}
public function pageno( )
{
return $this->page;
}
public function setdrawcolor( $r, $g = null, $b = null )
{
if ( $r == 0 && $g == 0 && $b == 0 || $g === null )
{
$this->DrawColor = ( "%.3F G", $r / 255 );
}
else
{
$this->DrawColor = ( "%.3F %.3F %.3F RG", $r / 255, $g / 255, $b / 255 );
}
if ( 0 < $this->page )
{
$this->_out( $this->DrawColor );
}
}
public function setfillcolor( $r, $g = null, $b = null )
{
if ( $r == 0 && $g == 0 && $b == 0 || $g === null )
{
$this->FillColor = ( "%.3F g", $r / 255 );
}
else
{
$this->FillColor = ( "%.3F %.3F %.3F rg", $r / 255, $g / 255, $b / 255 );
}
$this->ColorFlag = $this->FillColor != $this->TextColor;
if ( 0 < $this->page )
{
$this->_out( $this->FillColor );
}
}
public function settextcolor( $r, $g = null, $b = null )
{
if ( $r == 0 && $g == 0 && $b == 0 || $g === null )
{
$this->TextColor = ( "%.3F g", $r / 255 );
}
else
{
$this->TextColor = ( "%.3F %.3F %.3F rg", $r / 255, $g / 255, $b / 255 );
}
$this->ColorFlag = $this->FillColor != $this->TextColor;
}
public function getstringwidth( $s )
{
$s = ( string )$s;
$cw =& $this->CurrentFont['cw'];
$w = 0;
$l = ( $s );
$i = 0;
while ( $i < $l )
{
$w += $cw[$s[$i]];
++$i;
}
return $w * $this->FontSize / 1000;
}
public function setlinewidth( $width )
{
$this->LineWidth = $width;
if ( 0 < $this->page )
{
$this->_out( ( "%.2F w", $width * $this->k ) );
}
}
public function line( $x1, $y1, $x2, $y2 )
{
$this->_out( ( "%.2F %.2F m %.2F %.2F l S", $x1 * $this->k, ( $this->h - $y1 ) * $this->k, $x2 * $this->k, ( $this->h - $y2 ) * $this->k ) );
}
public function rect( $x, $y, $w, $h, $style = "" )
{
if ( $style == "F" )
{
$op = "f";
}
else if ( $style == "FD" || $style == "DF" )
{
$op = "B";
}
else
{
$op = "S";
}
$this->_out( ( "%.2F %.2F %.2F %.2F re %s", $x * $this->k, ( $this->h - $y ) * $this->k, $w * $this->k, 0 - $h * $this->k, $op ) );
}
public function addfont( $family, $style = "", $file = "" )
{
$family = ( $family );
if ( $file == "" )
{
$file = ( " ", "", $family ).( $style ).".php";
}
if ( $family == "arial" )
{
$family = "helvetica";
}
$style = ( $style );
if ( $style == "IB" )
{
$style = "BI";
}
$fontkey = $family.$style;
if ( isset( $this->fonts[$fontkey] ) )
{
return;
}
include( $this->_getfontpath( ).$file );
if ( !isset( "name" ) )
{
$this->Error( "Could not include font definition file" );
}
$i = ( $this->fonts ) + 1;
$this->fonts[$fontkey] = array(
"i" => $i,
"type" => $type,
"name" => $name,
"desc" => $desc,
"up" => $up,
"ut" => $ut,
"cw" => $cw,
"enc" => $enc,
"file" => $file
);
if ( $diff )
{
$d = 0;
$nb = ( $this->diffs );
$i = 1;
while ( $i <= $nb )
{
if ( $this->diffs[$i] == $diff )
{
$d = $i;
break;
}
++$i;
}
if ( $d == 0 )
{
$d = $nb + 1;
$this->diffs[$d] = $diff;
}
$this->fonts[$fontkey]['diff'] = $d;
}
if ( $file )
{
if ( $type == "TrueType" )
{
$this->FontFiles[$file] = array(
"length1" => $originalsize
);
}
else
{
$this->FontFiles[$file] = array(
"length1" => $size1,
"length2" => $size2
);
}
}
}
public function setfont( $family, $style = "", $size = 0 )
{
global $fpdf_charwidths;
$family = ( $family );
if ( $family == "" )
{
$family = $this->FontFamily;
}
if ( $family == "arial" )
{
$family = "helvetica";
}
else if ( $family == "symbol" || $family == "zapfdingbats" )
{
$style = "";
}
$style = ( $style );
if ( ( $style, "U" ) !== false )
{
$this->underline = true;
$style = ( "U", "", $style );
}
else
{
$this->underline = false;
}
if ( $style == "IB" )
{
$style = "BI";
}
if ( $size == 0 )
{
$size = $this->FontSizePt;
}
if ( $this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size )
{
return;
}
$fontkey = $family.$style;
if ( !isset( $this->fonts[$fontkey] ) )
{
if ( isset( $this->CoreFonts[$fontkey] ) )
{
if ( !isset( $fpdf_charwidths[$fontkey] ) )
{
$file = $family;
if ( $family == "times" || $family == "helvetica" )
{
$file .= ( $style );
}
include( $this->_getfontpath( ).$file.".php" );
if ( !isset( $fpdf_charwidths[$fontkey] ) )
{
$this->Error( "Could not include font metric file" );
}
}
$i = ( $this->fonts ) + 1;
$name = $this->CoreFonts[$fontkey];
$cw = $fpdf_charwidths[$fontkey];
$this->fonts[$fontkey] = array(
"i" => $i,
"type" => "core",
"name" => $name,
"up" => 0 - 100,
"ut" => 50,
"cw" => $cw
);
}
else
{
$this->Error( "Undefined font: ".$family." ".$style );
}
}
$this->FontFamily = $family;
$this->FontStyle = $style;
$this->FontSizePt = $size;
$this->FontSize = $size / $this->k;
$this->CurrentFont =& $this->fonts[$fontkey];
if ( 0 < $this->page )
{
$this->_out( ( "BT /F%d %.2F Tf ET", $this->CurrentFont['i'], $this->FontSizePt ) );
}
}
public function setfontsize( $size )
{
if ( $this->FontSizePt == $size )
{
return;
}
$this->FontSizePt = $size;
$this->FontSize = $size / $this->k;
if ( 0 < $this->page )
{
$this->_out( ( "BT /F%d %.2F Tf ET", $this->CurrentFont['i'], $this->FontSizePt ) );
}
}
public function addlink( )
{
$n = ( $this->links ) + 1;
$this->links[$n] = array( 0, 0 );
return $n;
}
public function setlink( $link, $y = 0, $page = -1 )
{
if ( $y == 0 - 1 )
{
$y = $this->y;
}
if ( $page == 0 - 1 )
{
$page = $this->page;
}
$this->links[$link] = array(
$page,
$y
);
}
public function link( $x, $y, $w, $h, $link )
{
$this->PageLinks[$this->page][] = array(
$x * $this->k,
$this->hPt - $y * $this->k,
$w * $this->k,
$h * $this->k,
$link
);
}
public function text( $x, $y, $txt )
{
$s = ( "BT %.2F %.2F Td (%s) Tj ET", $x * $this->k, ( $this->h - $y ) * $this->k, $this->_escape( $txt ) );
if ( $this->underline && $txt != "" )
{
$s .= " ".$this->_dounderline( $x, $y, $txt );
}
if ( $this->ColorFlag )
{
$s = "q ".$this->TextColor." ".$s." Q";
}
$this->_out( $s );
}
public function acceptpagebreak( )
{
return $this->AutoPageBreak;
}
public function cell( $w, $h = 0, $txt = "", $border = 0, $ln = 0, $align = "", $fill = false, $link = "" )
{
$k = $this->k;
if ( $this->PageBreakTrigger < $this->y + $h && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak( ) )
{
$x = $this->x;
$ws = $this->ws;
if ( 0 < $ws )
{
$this->ws = 0;
$this->_out( "0 Tw" );
}
$this->AddPage( $this->CurOrientation, $this->CurPageFormat );
$this->x = $x;
if ( 0 < $ws )
{
$this->ws = $ws;
$this->_out( ( "%.3F Tw", $ws * $k ) );
}
}
if ( $w == 0 )
{
$w = $this->w - $this->rMargin - $this->x;
}
$s = "";
if ( $fill || $border == 1 )
{
if ( $fill )
{
$op = $border == 1 ? "B" : "f";
}
else
{
$op = "S";
}
$s = ( "%.2F %.2F %.2F %.2F re %s ", $this->x * $k, ( $this->h - $this->y ) * $k, $w * $k, 0 - $h * $k, $op );
}
if ( ( $border ) )
{
$x = $this->x;
$y = $this->y;
if ( ( $border, "L" ) !== false )
{
$s .= ( "%.2F %.2F m %.2F %.2F l S ", $x * $k, ( $this->h - $y ) * $k, $x * $k, ( $this->h - ( $y + $h ) ) * $k );
}
if ( ( $border, "T" ) !== false )
{
$s .= ( "%.2F %.2F m %.2F %.2F l S ", $x * $k, ( $this->h - $y ) * $k, ( $x + $w ) * $k, ( $this->h - $y ) * $k );
}
if ( ( $border, "R" ) !== false )
{
$s .= ( "%.2F %.2F m %.2F %.2F l S ", ( $x + $w ) * $k, ( $this->h - $y ) * $k, ( $x + $w ) * $k, ( $this->h - ( $y + $h ) ) * $k );
}
if ( ( $border, "B" ) !== false )
{
$s .= ( "%.2F %.2F m %.2F %.2F l S ", $x * $k, ( $this->h - ( $y + $h ) ) * $k, ( $x + $w ) * $k, ( $this->h - ( $y + $h ) ) * $k );
}
}
if ( $txt !== "" )
{
if ( $align == "R" )
{
$dx = $w - $this->cMargin - $this->GetStringWidth( $txt );
}
else if ( $align == "C" )
{
$dx = ( $w - $this->GetStringWidth( $txt ) ) / 2;
}
else
{
$dx = $this->cMargin;
}
if ( $this->ColorFlag )
{
$s .= "q ".$this->TextColor." ";
}
$txt2 = ( ")", "\\)", ( "(", "\\(", ( "\\", "\\\\", $txt ) ) );
$s .= ( "BT %.2F %.2F Td (%s) Tj ET", ( $this->x + $dx ) * $k, ( $this->h - ( $this->y + 0.5 * $h + 0.3 * $this->FontSize ) ) * $k, $txt2 );
if ( $this->underline )
{
$s .= " ".$this->_dounderline( $this->x + $dx, $this->y + 0.5 * $h + 0.3 * $this->FontSize, $txt );
}
if ( $this->ColorFlag )
{
$s .= " Q";
}
if ( $link )
{
$this->Link( $this->x + $dx, $this->y + 0.5 * $h - 0.5 * $this->FontSize, $this->GetStringWidth( $txt ), $this->FontSize, $link );
}
}
if ( $s )
{
$this->_out( $s );
}
$this->lasth = $h;
if ( 0 < $ln )
{
$this->y += $h;
if ( $ln == 1 )
{
$this->x = $this->lMargin;
}
}
else
{
$this->x += $w;
}
}
public function multicell( $w, $h, $txt, $border = 0, $align = "J", $fill = false )
{
$cw =& $this->CurrentFont['cw'];
if ( $w == 0 )
{
$w = $this->w - $this->rMargin - $this->x;
}
$wmax = ( $w - 2 * $this->cMargin ) * 1000 / $this->FontSize;
$s = ( "\r", "", $txt );
$nb = ( $s );
if ( 0 < $nb && $s[$nb - 1] == "\n" )
{
--$nb;
}
$b = 0;
if ( $border )
{
if ( $border == 1 )
{
$border = "LTRB";
$b = "LRT";
$b2 = "LR";
}
else
{
$b2 = "";
if ( ( $border, "L" ) !== false )
{
$b2 .= "L";
}
if ( ( $border, "R" ) !== false )
{
$b2 .= "R";
}
$b = ( $border, "T" ) !== false ? $b2."T" : $b2;
}
}
$sep = 0 - 1;
$i = 0;
$j = 0;
$l = 0;
$ns = 0;
$nl = 1;
while ( $i < $nb )
{
$c = $s[$i];
if ( $c == "\n" )
{
if ( 0 < $this->ws )
{
$this->ws = 0;
$this->_out( "0 Tw" );
}
$this->Cell( $w, $h, ( $s, $j, $i - $j ), $b, 2, $align, $fill );
++$i;
$sep = 0 - 1;
$j = $i;
$l = 0;
$ns = 0;
++$nl;
if ( $border && $nl == 2 )
{
$b = $b2;
}
continue;
}
if ( $c == " " )
{
$sep = $i;
$ls = $l;
++$ns;
}
$l += $cw[$c];
if ( $wmax < $l )
{
if ( $sep == 0 - 1 )
{
if ( $i == $j )
{
++$i;
}
if ( 0 < $this->ws )
{
$this->ws = 0;
$this->_out( "0 Tw" );
}
$this->Cell( $w, $h, ( $s, $j, $i - $j ), $b, 2, $align, $fill );
}
else
{
if ( $align == "J" )
{
$this->ws = 1 < $ns ? ( $wmax - $ls ) / 1000 * $this->FontSize / ( $ns - 1 ) : 0;
$this->_out( ( "%.3F Tw", $this->ws * $this->k ) );
}
$this->Cell( $w, $h, ( $s, $j, $sep - $j ), $b, 2, $align, $fill );
$i = $sep + 1;
}
$sep = 0 - 1;
$j = $i;
$l = 0;
$ns = 0;
++$nl;
if ( $border && $nl == 2 )
{
$b = $b2;
}
}
else
{
++$i;
}
}
if ( 0 < $this->ws )
{
$this->ws = 0;
$this->_out( "0 Tw" );
}
if ( $border && ( $border, "B" ) !== false )
{
$b .= "B";
}
$this->Cell( $w, $h, ( $s, $j, $i - $j ), $b, 2, $align, $fill );
$this->x = $this->lMargin;
}
public function write( $h, $txt, $link = "" )
{
$cw =& $this->CurrentFont['cw'];
$w = $this->w - $this->rMargin - $this->x;
$wmax = ( $w - 2 * $this->cMargin ) * 1000 / $this->FontSize;
$s = ( "\r", "", $txt );
$nb = ( $s );
$sep = 0 - 1;
$i = 0;
$j = 0;
$l = 0;
$nl = 1;
while ( $i < $nb )
{
$c = $s[$i];
if ( $c == "\n" )
{
$this->Cell( $w, $h, ( $s, $j, $i - $j ), 0, 2, "", 0, $link );
++$i;
$sep = 0 - 1;
$j = $i;
$l = 0;
if ( $nl == 1 )
{
$this->x = $this->lMargin;
$w = $this->w - $this->rMargin - $this->x;
$wmax = ( $w - 2 * $this->cMargin ) * 1000 / $this->FontSize;
}
++$nl;
continue;
}
if ( $c == " " )
{
$sep = $i;
}
$l += $cw[$c];
if ( $wmax < $l )
{
if ( $sep == 0 - 1 )
{
if ( $this->lMargin < $this->x )
{
$this->x = $this->lMargin;
$this->y += $h;
$w = $this->w - $this->rMargin - $this->x;
$wmax = ( $w - 2 * $this->cMargin ) * 1000 / $this->FontSize;
++$i;
++$nl;
continue;
}
if ( $i == $j )
{
++$i;
}
$this->Cell( $w, $h, ( $s, $j, $i - $j ), 0, 2, "", 0, $link );
}
else
{
$this->Cell( $w, $h, ( $s, $j, $sep - $j ), 0, 2, "", 0, $link );
$i = $sep + 1;
}
$sep = 0 - 1;
$j = $i;
$l = 0;
if ( $nl == 1 )
{
$this->x = $this->lMargin;
$w = $this->w - $this->rMargin - $this->x;
$wmax = ( $w - 2 * $this->cMargin ) * 1000 / $this->FontSize;
}
++$nl;
}
else
{
++$i;
}
}
if ( $i != $j )
{
$this->Cell( $l / 1000 * $this->FontSize, $h, ( $s, $j ), 0, 0, "", 0, $link );
}
}
public function ln( $h = null )
{
$this->x = $this->lMargin;
if ( $h === null )
{
$this->y += $this->lasth;
}
else
{
$this->y += $h;
}
}
public function image( $file, $x = null, $y = null, $w = 0, $h = 0, $type = "", $link = "" )
{
if ( !isset( $this->images[$file] ) )
{
if ( $type == "" )
{
$pos = ( $file, "." );
if ( !$pos )
{
$this->Error( "Image file has no extension and no type was specified: ".$file );
}
$type = ( $file, $pos + 1 );
}
$type = ( $type );
if ( $type == "jpeg" )
{
$type = "jpg";
}
$mtd = "_parse".$type;
if ( !( $this, $mtd ) )
{
$this->Error( "Unsupported image type: ".$type );
}
$info = $this->$mtd( $file );
$info['i'] = ( $this->images ) + 1;
$this->images[$file] = $info;
}
else
{
$info = $this->images[$file];
}
if ( $w == 0 && $h == 0 )
{
$w = $info['w'] / $this->k;
$h = $info['h'] / $this->k;
}
else if ( $w == 0 )
{
$w = $h * $info['w'] / $info['h'];
}
else if ( $h == 0 )
{
$h = $w * $info['h'] / $info['w'];
}
if ( $y === null )
{
if ( $this->PageBreakTrigger < $this->y + $h && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak( ) )
{
$x2 = $this->x;
$this->AddPage( $this->CurOrientation, $this->CurPageFormat );
$this->x = $x2;
}
$y = $this->y;
$this->y += $h;
}
if ( $x === null )
{
$x = $this->x;
}
$this->_out( ( "q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q", $w * $this->k, $h * $this->k, $x * $this->k, ( $this->h - ( $y + $h ) ) * $this->k, $info['i'] ) );
if ( $link )
{
$this->Link( $x, $y, $w, $h, $link );
}
}
public function getx( )
{
return $this->x;
}
public function setx( $x )
{
if ( 0 <= $x )
{
$this->x = $x;
}
else
{
$this->x = $this->w + $x;
}
}
public function gety( )
{
return $this->y;
}
public function sety( $y )
{
$this->x = $this->lMargin;
if ( 0 <= $y )
{
$this->y = $y;
}
else
{
$this->y = $this->h + $y;
}
}
public function setxy( $x, $y )
{
$this->SetY( $y );
$this->SetX( $x );
}
public function output( $name = "", $dest = "" )
{
if ( $this->state < 3 )
{
$this->Close( );
}
$dest = ( $dest );
if ( $dest == "" )
{
if ( $name == "" )
{
$name = "doc.pdf";
$dest = "I";
}
else
{
$dest = "F";
}
}
switch ( $dest )
{
case "I" :
if ( ( ) )
{
$this->Error( "Some data has already been output, can't send PDF file" );
}
if ( ( ) != "cli" )
{
( "Content-Type: application/pdf" );
if ( ( ) )
{
$this->Error( "Some data has already been output, can't send PDF file" );
}
( "Content-Length: ".( $this->buffer ) );
( "Content-Disposition: inline; filename=\"".$name."\"" );
( "Cache-Control: private, max-age=0, must-revalidate" );
( "Pragma: public" );
( "zlib.output_compression", "0" );
}
echo $this->buffer;
break;
case "D" :
if ( ( ) )
{
$this->Error( "Some data has already been output, can't send PDF file" );
}
( "Content-Type: application/x-download" );
if ( ( ) )
{
$this->Error( "Some data has already been output, can't send PDF file" );
}
( "Content-Length: ".( $this->buffer ) );
( "Content-Disposition: attachment; filename=\"".$name."\"" );
( "Cache-Control: private, max-age=0, must-revalidate" );
( "Pragma: public" );
( "zlib.output_compression", "0" );
echo $this->buffer;
break;
case "F" :
$f = ( $name, "wb" );
if ( !$f )
{
$this->Error( "Unable to create output file: ".$name );
}
( $f, $this->buffer, ( $this->buffer ) );
( $f );
break;
case "S" :
return $this->buffer;
default :
$this->Error( "Incorrect output destination: ".$dest );
}
return "";
}
public function _dochecks( )
{
if ( ( "%.1F", 1 ) != "1.0" )
{
$this->Error( "This version of PHP is not supported" );
}
if ( ( "mbstring.func_overload" ) & 2 )
{
$this->Error( "mbstring overloading must be disabled" );
}
if ( ( ) )
{
@( 0 );
}
}
public function _getpageformat( $format )
{
$format = ( $format );
if ( !isset( $this->PageFormats[$format] ) )
{
$this->Error( "Unknown page format: ".$format );
}
$a = $this->PageFormats[$format];
return array(
$a[0] / $this->k,
$a[1] / $this->k
);
}
public function _getfontpath( )
{
if ( !( "FPDF_FONTPATH" ) && ( ( "I:\\jiemi\\bin\\rm\\file.php" )."/font" ) )
{
( "FPDF_FONTPATH", ( "I:\\jiemi\\bin\\rm\\file.php" )."/font/" );
}
return ( "FPDF_FONTPATH" ) ? FPDF_FONTPATH : "";
}
public function _beginpage( $orientation, $format )
{
++$this->page;
$this->pages[$this->page] = "";
$this->state = 2;
$this->x = $this->lMargin;
$this->y = $this->tMargin;
$this->FontFamily = "";
if ( $orientation == "" )
{
$orientation = $this->DefOrientation;
}
else
{
$orientation = ( $orientation[0] );
}
if ( $format == "" )
{
$format = $this->DefPageFormat;
}
else if ( ( $format ) )
{
$format = $this->_getpageformat( $format );
}
if ( $orientation != $this->CurOrientation || $format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1] )
{
if ( $orientation == "P" )
{
$this->w = $format[0];
$this->h = $format[1];
}
else
{
$this->w = $format[1];
$this->h = $format[0];
}
$this->wPt = $this->w * $this->k;
$this->hPt = $this->h * $this->k;
$this->PageBreakTrigger = $this->h - $this->bMargin;
$this->CurOrientation = $orientation;
$this->CurPageFormat = $format;
}
if ( $orientation != $this->DefOrientation || $format[0] != $this->DefPageFormat[0] || $format[1] != $this->DefPageFormat[1] )
{
$this->PageSizes[$this->page] = array(
$this->wPt,
$this->hPt
);
}
}
public function _endpage( )
{
$this->state = 1;
}
public function _escape( $s )
{
$s = ( "\\", "\\\\", $s );
$s = ( "(", "\\(", $s );
$s = ( ")", "\\)", $s );
$s = ( "\r", "\\r", $s );
return $s;
}
public function _textstring( $s )
{
return "(".$this->_escape( $s ).")";
}
public function _utf8toutf16( $s )
{
$res = "?";
$nb = ( $s );
$i = 0;
while ( $i < $nb )
{
$c1 = ( $s[$i++] );
if ( 224 <= $c1 )
{
$c2 = ( $s[$i++] );
$c3 = ( $s[$i++] );
[exception occured]
================================
Exception code[ C0000005 ]
Compiler[ 00284258 ]
Executor[ 002846E0 ]
OpArray[ 004C9370 ]
File< main >
Class< fpdf >
Function< _utf8toutf16 >
Stack[ 0057F950 ]
Step[ 7 ]
Offset[ 53 ]
LastOffset[ 112 ]
53 ADD [-] 0[0] $Tmp_42 - $Tmp_38 - $Tmp_41
================================
?>
|
|