<?php
class PDF extends FPDF{
//***********************************************************************************************
// EXTRA FUNCTIONS FOR HUMOGEN BY YOSSI BECK : pdfdisplay() , displayrel() , writename(), kwartiernaam() and adjusted Header()
//************************************************************************************************
//**********************************************************************************************
// function pdfdisplay() to display details of person from array returned by person_cls.php
//
// it parses the values and places them as needed, including pictures and their text, links to parents
// it also places "Born:" "Died:" etc before their text (even though in the array they come after the text)
//**********************************************************************************************
function pdfdisplay($pdfstring,$soortpers) {
global $pdf, $language, $gen_lus;
global $romnr, $romannr, $parentchild, $parlink;
global $indent, $child_indent;
$largest_height=0;
$pic=array();
$picarray=array();
$numpics=0;
$tallestpic=0; $tallesttext=0;
if($soortpers !="kind") {
$font=12; $type='';
}
else {
$font=11; $type='';
}
$first=0; $born=0; $bapt=0; $dead=0; $buri=0; // check if we have first occurance of birth, death etc. data, so we add "Born", "Died", etc.
foreach ($pdfstring as $key => $value) {
$pdf->SetFont('Arial',$type,$font);
if(strpos($key,"pic_path")!==false) {
if(strpos($value,".jpeg")!==false OR strpos($value,".jpg")!==false OR strpos($value,".gif")!==false OR strpos($value,".png")!==false) {
if(is_file($value)) {
if($numpics > 2) {continue;} // no more than 3 pics
$presentpic=intval(substr($key,8)); //get the pic nr to compare later with txt nr
$picarray[$numpics][0]=$value;
$size=getimagesize($value);
$height=$size[1];
$width=$size[0];
if($width > 180) { //narrow and wide thumbs should not get height 120px - they will be far too long
$height*= 180/$width;
$width=180;
}
//if($height > $tallestpic) { $tallestpic=$height; }
$picarray[$numpics][1]=$width/3.87; // turn px into mm for pdf
$picarray[$numpics][4]=$height/3.87; // turn px into mm for pdf
if($picarray[$numpics][4] > $tallestpic) { $tallestpic = $picarray[$numpics][4]; }
$numpics++;
}
}
continue;
}
if(strpos($key,"pic_text")!==false) {
if(isset($presentpic) AND $presentpic==intval(substr($key,8))) {
$picarray[$numpics-1][2]=$value;
if(isset($picarray[$numpics-1][2])) {
$textlines=ceil(strlen($value)/33);
$totalheight=($textlines*5) + ($picarray[$numpics-1][4]);
if( $totalheight > $tallestpic) { $tallestpic=$totalheight; }
}
}
continue;
}
if(strpos($key,"flag_buri")!==false) {
continue;
}
if(!$born) {
if(strpos($key,"born")!==false) {
$value=", ".$language["pers_born"].$value;
$born=1;
}
}
if(!$bapt) {
if(strpos($key,"bapt")!==false) {
$value=", ".$language["pers_baptised"].$value;
$bapt=1;
}
}
if(!$dead) {
if(strpos($key,"dead")!==false) {
$value=", ".$language["pers_died"].$value;
$dead=1;
}
}
if(!$buri) {
if(strpos($key,"buri")!==false) {
if($pdfstring["flag_buri"]==1) {
$value=", ".$language["pers_cremation"].$value;
}
else {
$value=", ".$language["pers_buried"].$value;
}
$buri=1;
}
}
if(!$first) {
if (substr($value,0,2)==', '){ $value=ucfirst(substr($value,2)); }
else {ucfirst($value); }
$first=1;
}
$value=html_entity_decode($value);
if(strpos($key,"text")!==false) { $pdf->SetFont('Arial','I',$font-1); }
if(strpos($key,"source")!==false OR strpos($key,"witn")!==false) { $pdf->SetFont('Times','',$font); }
if(strpos($key,"parent")!==false) {
if($soortpers=="parent1" AND $key=="parents" AND $gen_lus!=0) {
$pdf->SetTextColor(28,28,255);
$pdf->SetFont('Arial','U',$font);
$temp=$parentchild[$romannr];
$pdf->Write(6,$value,$parlink[$temp]);
$pdf->SetTextColor(0);
}
elseif($key=="parents"){
$pdf->SetFont('Arial','B',$font);
$pdf->Write(6,$value);
}
else {
$pdf->SetFont('Arial','',$font);
$pdf->Write(6,$value);
}
}
else {
if($soortpers=="kind") {
$pdf->SetLeftMargin($child_indent);
$pdf->Write(6,$value);
$pdf->SetLeftMargin($indent);
}
elseif($soortpers=="kwartier") {
if(strpos($key,"got_pics")!==false) {
$keepY=$pdf->GetY()+7; if(($keepY + $tallestpic) > 280) {$pdf->AddPage(); $keepY=20; }
$keepX=$pdf->GetX();
if(isset($picarray[0][0])) { // we got at least 1 pic
$pic_indent=40; $pictext_indent=27;
for($i=0; $i <3 ; $i++) {
if(isset($picarray[$i][0])) {
$pdf->Image($picarray[$i][0],$pic_indent,$keepY,$picarray[$i][1]);
$pic_indent+= ($picarray[$i][1] + 31);
if(isset($picarray[$i][2])) {
$pdf->SetFont('Arial','',8);
$pdf->SetXY($pictext_indent,$keepY+$picarray[$i][4]+1);
$pictext_indent+= 26 + $picarray[$i][1] + 5;
$pdf->MultiCell(26+$picarray[$i][1],4,$picarray[$i][2],0,'C');
}
}
}
$pdf->SetXY($keepX,$keepY+$tallestpic-7);
}
}
else {
$pdf->SetLeftMargin(38);
$pdf->Write(6,$value);
$pdf->SetLeftMargin(10);
}
}
elseif(strpos($key,"got_pics")!==false) {
$keepY=$pdf->GetY()+7; if(($keepY + $tallestpic) > 280) {$pdf->AddPage(); $keepY=20; }
$keepX=$pdf->GetX();
if(isset($picarray[0][0])) { // we got at least 1 pic
$pictext_indent=22; $pic_indent=35;
for($i=0; $i <3 ; $i++) {
if(isset($picarray[$i][0])) {
$pdf->Image($picarray[$i][0],$pic_indent,$keepY,$picarray[$i][1] );
$pic_indent+= ($picarray[$i][1] + 31);
if(isset($picarray[$i][2])) {
$pdf->SetFont('Arial','',8);
$pdf->SetXY($pictext_indent,$keepY+$picarray[$i][4]+1);
$pictext_indent+= 26 + $picarray[$i][1] + 5;
$pdf->MultiCell(26+$picarray[$i][1],4,$picarray[$i][2],0,'C');
}
}
}
$pdf->SetXY($keepX,$keepY+$tallestpic-7);
}
}
else {
$pdf->Write(6,$value);
}
}
$pdf->SetFont('Arial',$type,$font);
}
if($soortpers!="kind") {
$pdf->Write(8,"\n");
}
else {
$pdf->Write(6,"\n");
}
} // end function display details
// ***********************************************************************************
// function displayrel() to display wedding/relation details from marriage_cls.php
// ***********************************************************************************
function displayrel ($pdfrel,$kwartier) {
global $pdf, $language;
$font=12;
$samw=0; $prew=0; $wedd=0; $prec=0; $chur=0; $devr=0;
foreach($pdfrel as $key => $value) {
$value=html_entity_decode($value);
$pdf->SetFont('Arial','',$font);
if(strpos($key,"exist")!==false) { continue; }
if($kwartier=="kwartier") {
$pdf->SetLeftMargin(38);
}
if(strpos($key,"samw")!==false AND $samw==0) { $pdf->Write(6,html_entity_decode($pdfrel["samw_exist"])); $samw=1; }
if(strpos($key,"prew")!==false AND $prew==0) { $pdf->Write(6,html_entity_decode($pdfrel["prew_exist"])); $prew=1; }
if(strpos($key,"wedd")!==false AND $wedd==0) { $pdf->Write(6,html_entity_decode($pdfrel["wedd_exist"])); $wedd=1;}
if(strpos($key,"prec")!==false AND $prec==0) { $pdf->Write(6,html_entity_decode($pdfrel["prec_exist"])); $prec=1; }
if(strpos($key,"chur")!==false AND $chur==0) { $pdf->Write(6,html_entity_decode($pdfrel["chur_exist"])); $chur=1; }
if(strpos($key,"devr")!==false AND $devr==0) { $pdf->Write(6,html_entity_decode($pdfrel["devr_exist"])); $devr=1; }
if(strpos($key,"text")!==false) { $pdf->SetFont('Arial','I',$font-1); }
if(strpos($key,"source")!==false OR strpos($key,"witn")!==false) { $pdf->SetFont('Times','',$font); }
if($kwartier=="kwartier") {
$pdf->Write(6,$value); $pdf->SetLeftMargin(10);
}
else {
$pdf->Write(6,$value);
}
}
$pdf->Write(8,"\n");
}
//*******************************************************************
// function writename() to place the name of a person
//*******************************************************************
function writename($sexe,$indentation,$name,$length) {
global $pdf, $language, $indent;
if($sexe=="M") {
$pic="images/man.gif";
}
elseif ($sexe=='F') {
$pic="images/woman.gif";
}
else{
$pic="images/unknown.gif";
}
$pdf->Image($pic,$indentation-4,$pdf->GetY()+2,3.5,3.5);
$pdf->SetX($indentation);
if($length=="long") {
$indent=$pdf->GetX();
}
$pdf->SetFont('Arial','B',12);
// $pdf->Write(8,$name);
$pdf->MultiCell(0,8,$name,0,"L");
$pdf->SetFont('Arial','',12);
// $pdf->Write(8,"\n");
}
//**********************************************************************
// function kwartiernaam() writes names in ancestor report (kwartierstaat)
//********************************************************************
function kwartiernaam($kwartiernr,$sexe, $name) {
global $pdf, $language;
$pdf->SetFont('Arial','B',12);
if($kwartiernr>9999) { // (num) will be placed under num
if($pdf->GetY()+7 >270) { //(num) would drop off bottom of page
$pdf->AddPage(); // move num already to new page so they stay together...
}
}
$pdf->Write(8,$kwartiernr);
$pdf->SetFont('Arial','',12);
if($kwartiernr>9999) { // num(num) becomes too long. (num) is placed 1 line down
$pdf->Ln(7);
$pdf->Write(8,'('.floor($kwartiernr/2).') ');
$pdf->SetY($pdf->GetY()-7); //get back to first line to place name
}
else {
$pdf->Write(8,' ('.floor($kwartiernr/2).') ');
}
$pdf->SetFont('Arial','B',12);
$pdf->SetX(35);
if($sexe=="M") {
$pdf->Image("images/man.gif",$pdf->GetX(),$pdf->GetY()+2,3.5,3.5);
}
elseif($sexe=="F") {
$pdf->Image("images/woman.gif",$pdf->GetX(),$pdf->GetY()+2,3.5,3.5);
}
else{
$pdf->Image("images/unknown.gif",$pdf->GetX(),$pdf->GetY()+2,3.5,3.5);
}
$pdf->SetX($pdf->GetX()+3);
$pdf->MultiCell(0,8,$name,0,"L");
$pdf->SetFont('Arial','',12);
}
//***************************
function Header(){
global $title;
if($this->PageNo()!=1) {
//Position at 1.0 cm from top
$this->SetY(10);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Text color in gray
$this->SetTextColor(128);
//Page description
$this->Cell(0,5,$title,0,1,'C');
$this->Ln(5);
}
}
/* // original fpdf version - if ever needed
function Header()
{
global $title;
//Arial bold 15
$this->SetFont('Arial','B',15);
//Calculate width of title and position
$w=$this->GetStringWidth($title)+6;
$this->SetX((210-$w)/2);
//Colors of frame, background and text
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
//Thickness of frame (1 mm)
$this->SetLineWidth(1);
//Title
$this->Cell($w,9,$title,1,1,'C',true);
//Line break
$this->Ln(10);
}
*/
function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Text color in gray
$this->SetTextColor(128);
//Page number
$this->Cell(0,10,'PDF Created with HuMo-gen (PHP) Page '.$this->PageNo(),0,0,'C');
}
} // end class that extends the pdf class
?>