Cezpdf($paper,$orientation); $this->MAXHEIGHT = $this->ez['pageHeight']; $this->MAXWIDTH = $this->ez['pageWidth']; $this->SECTIONLENGTH = $this->MAXHEIGHT/4; $this->SIDE_INDENT = 25; } function DrawLines() { $MAXHEIGHT = $this->MAXHEIGHT; $MAXWIDTH = $this->MAXWIDTH; $SIDE_INDENT = $this->SIDE_INDENT; $SECTION_LENGTH = $this->SECTIONLENGTH; #bad name. this is the distance from the vertical the drop portion of the slope $ANGLE_INSET = 25; $BLACK = 0; $GRAY=array(.5,.5,.5); #vertical middle $this->Line($MAXWIDTH/2,0,$MAXWIDTH/2,$MAXHEIGHT); #vertical side left $this->Line($SIDE_INDENT,0,$SIDE_INDENT,$MAXHEIGHT); #vertical side right $this->Line($MAXWIDTH - $SIDE_INDENT,0,$MAXWIDTH - $SIDE_INDENT,$MAXHEIGHT); #horizontal middle $this->Line(0 + $SIDE_INDENT,$MAXHEIGHT/2,$MAXWIDTH - $SIDE_INDENT,$MAXHEIGHT/2); #horizontal 1/4 $this->Line(0 + $SIDE_INDENT,$MAXHEIGHT/4,$MAXWIDTH - $SIDE_INDENT,$MAXHEIGHT/4); #horizontal 3/4 $this->Line(0+ $SIDE_INDENT,3*$MAXHEIGHT/4,$MAXWIDTH - $SIDE_INDENT,3*$MAXHEIGHT/4); #make 8 cut ticks on each side. #$this->SetDrawColor($GRAY); $this->SetStrokeColor(.50,.50,.50); $this->setLineStyle(1,'','',array(2,1)); for ($i=0;$i <4; $i++) { $height = $i * ($SECTION_LENGTH); $this->Line(0,$height+ $ANGLE_INSET, $SIDE_INDENT,$height); $this->Line(0,$height + $SECTION_LENGTH - $ANGLE_INSET, $SIDE_INDENT, $height+$SECTION_LENGTH); $this->Line($MAXWIDTH - $SIDE_INDENT,$height,$MAXWIDTH,$height+$ANGLE_INSET); $this->Line($MAXWIDTH - $SIDE_INDENT,$height + $SECTION_LENGTH, $MAXWIDTH, $height + $SECTION_LENGTH - $ANGLE_INSET); } // credit card pockets $this->curve(($MAXWIDTH/2),($MAXHEIGHT/2),($MAXWIDTH/2)-30,($MAXHEIGHT/2)-30,($MAXWIDTH/2)-30,($MAXHEIGHT/4)+30,($MAXWIDTH/2),($MAXHEIGHT/4)); $this->curve(($MAXWIDTH/2),($MAXHEIGHT/2),($MAXWIDTH/2)+30,($MAXHEIGHT/2)-30,($MAXWIDTH/2)+30,($MAXHEIGHT/4)+30,($MAXWIDTH/2),($MAXHEIGHT/4)); } function RenderTextBlock($text,$sectionsFromBottom, $isOnLeft, $isFlipped, $aleft, $aright, $fontsize=14,$fontname='georgia'){ $this->selectFont('../ezpdf/fonts/'.$fontname.'.afm'); $MAXHEIGHT = $this->MAXHEIGHT; $MAXWIDTH = $this->MAXWIDTH; $SECTION_LENGTH = $this->SECTIONLENGTH; $SECTIONSUP = $sectionsFromBottom; $padding = $MAXHEIGHT/($fontsize * 3); $padding = $padding * (.5 * max(0,floor(11-(strlen($text)/40)))); $angle = 0; if($isFlipped){ //rendering rotated text basically means you render it a little lower, then rotate it upwards. //it seems to revolve around the initial x y point. $SECTIONSUP = $SECTIONSUP - 1; $padding = $padding * -1; $angle = 180; } $this->ezSetY(($SECTION_LENGTH * $SECTIONSUP) - $padding); $this->setColor(0,0,0); $this->ezText($text,$fontsize,array('justification'=>'left','angle'=>$angle,'aright'=>$aright,'aleft'=>$aleft)); } function DrawText(){ $this->RenderTextBlock($this->FrontText,3,true,false,60,($this->MAXWIDTH/2 -15)); $this->RenderTextBlock($this->BackText,3,false,false, $this->MAXWIDTH/2 + 15, $this->MAXWIDTH -60); $this->RenderTextBlock($this->InsideLeftText,2,true,true,($this->MAXWIDTH/2 -30),$this->MAXWIDTH - 80); $this->RenderTextBlock($this->InsideRightText ,2,false,true,$this->MAXWIDTH-30,$this->MAXWIDTH + ($this->MAXWIDTH/2 -75)); } function RenderImageBlock($image,$sectionsFromBottom,$isOnLeft,$isFlipped){ if ($image != 'none') { list($imagewidth, $imageheight, $type, $attr) = getimagesize($image); $degrees = 0; if($isFlipped){ $degrees = 180; } if ($imagewidth < $imageheight) { $degrees += 90; } if($degrees > 0){ $source = imagecreatefromjpeg($image); $rotate = imagerotate($source, $degrees, 0); imagejpeg($rotate, $image); clearstatcache(); list($imagewidth, $imageheight, $type, $attr) = getimagesize($image); } //we should probably get rid of this magic number at some point. $hwRatio = ($this->SECTIONLENGTH)/(3.5*72); $imgRatio = $imageheight/$imagewidth; #if ($imgRatio < $hwRatio){ $printWidth = ((($this->SECTIONLENGTH)*$imagewidth)/$imageheight); #} $x = $this->MAXWIDTH/2; if($isOnLeft){ $x = $x - $printWidth; } $y = $this->SECTIONLENGTH * ($sectionsFromBottom - 1 ); $this->addJpegFromFile($image,$x,$y,$printWidth,$this->SECTIONLENGTH); } } function DrawImages(){ //render this on the left side right side up, 3 sections from the bottom $this->RenderImageBlock($this->FrontImage,3,true,false); //render this on the right side, right side up, 3 sections from the bottom $this->RenderImageBlock($this->BackImage,3,false,false); //render this on the right side - since that will be the left side of the fully folded wallet $this->RenderImageBlock($this->LeftInsideImage,2,false,true); //render this on the left side - since that will be the right side of the fully folded wallet $this->RenderImageBlock($this->RightInsideImage,2,true,true); } } ?>