Esempio n. 1
0
    ,Giver.* 
    ,Giver.ZipTown || ' ' || Giver.ZipCode as 'Giver.Post'
From 
    Fadderbarn
    ,Giver 
Where 
    Giver.Id = Fadderbarn.GiverId 
    AND Fadderbarn.Id = '$id'";

    $result = $db->Query($query);
    $row = $db->GetRow($result);
    
    $t = array('y'=>745,'align'=>'right','xStart'=>440,'xEnd'=>'540');
    alignedText($t,dbTexts('Giver.Id,Giver.Name,Giver.CoAddress,Giver.Address,Giver.Post',$row,'EOL'),$page,$offsety);
    $page->setFont($page->getFont(), 12);
    alignedText(array('y'=>596,'xStart'=>440,'xEnd'=>540,'align'=>'right'),"".date('Y-m-d')."",$page,$offsety);    $t = array('y'=>581,'align'=>'left','xStart'=>92,'xEnd'=>'540');
    alignedText($t,dbTexts('Giver.Name',$row,' '),$page,$offsety);
    $t = array('y'=>528,'align'=>'left','xStart'=>54,'xEnd'=>'540');
    alignedText($t,dbTexts('Fadderbarn.Id',$row,' '),$page,$offsety);
    $t = array('y'=>516,'align'=>'left','xStart'=>54,'xEnd'=>'540');
    alignedText($t,dbTexts('Fadderbarn.Name',$row,' '),$page,$offsety);
    $page->setFont($page->getFont(), 12);
    alignedText(array('y'=>502,'xStart'=>54,'xEnd'=>540,'align'=>'wrap'),"",$page,$offsety);

//output pdf inline

    header("Content-type: application/pdf");
    header("Content-Disposition: inline; filename=result.pdf");
    print $pdf->render();

Esempio n. 2
0
function inject($a,$pdfPage,$row,$offsety = 0) {
	global $db,$path;
	foreach($a as $t) {
			switch($t['type']) {
				case 'text':
					$pdfPage
						->setFont($pdfPage->getFont(), $t['fontSize']);
					;
					//alignedText($t,trim(@$row[$t['fieldName']]),$pdfPage,$offsety);
					$fields = explode(",",$t['fieldName']);
					$txt = "";
					foreach($fields as $field) {
						$txt .= $row[$field] . PHP_EOL;
					}
					alignedText($t,$txt,$pdfPage,$offsety);
					
				break;
				case 'cmd':
					switch($t['cmdName']) {
						case 'extratext':
							$pdfPage->setFont($pdfPage->getFont(), $t['fontSize']);
							alignedText($t,$t['extratext'],$pdfPage,$offsety);
						break;
						case 'rotate':
							$pdfPage->rotate(0, 0, deg2rad((float)$t['degrees']));
						break;
						case 'fontSize':
							$pdfPage->setFont($font, (float)$t['fontSize']);
						break;
						case 'font':
							$font = Zend_Pdf_Font::fontWithPath($path.'/fonts/'. $t['typeface'] .'.ttf',Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION); 
							$pdfPage->setFont($font, 12);
						break;
						case 'color':
							$pdfPage->setFillColor(new Zend_Pdf_Color_HTML($t['color']));
						break;
						case 'subReport':
							$subDatFile = "${path}".$t['subReportId'].".dat";
							$result = $db->Query("select * from CustomReport where Id='${t['subReportId']}'");
							if (file_exists($subDatFile)) {
								$sub = unserialize(file_get_contents($subDatFile));
							} else {
								$sub = array(
									array('type'=>'jsonInfo','nextId'=>1,'reportName'=>'CustomPDF','ReportId'=>$t['subReportId'])
								);
							}
							$sub[0] = array_merge($sub[0],$db->GetRow($result));
							//the set of commands is then going to be injected into the current page...
							$r = getQuery($sub,$row['_id']);
							$reportName = $r[1];
							
							$subResult = $db->Query($r[0]);
							$subOffsety = (float)$t['y'];
							while ($subRow = $db->GetRow($subResult)) {
								$subOffsety = inject($sub,$pdfPage,$subRow,$subOffsety);
								$subOffsety += (float)$t['ySize'];
							}
						break;
					}
				break;
			}
		}
	return $offsety;
}