Welcome Guest, Not a member yet? Register   Sign In
SOLVED - tcpdf Standard Header Not Printing
#1

[eluser]TerryT[/eluser]
Trying out tcpdf and can get my test report, but no header prints. My understanding is that calling AddPage should also call the header. Can anyone tell me why? I tried adjusting margins in the config file, but same result. Here's the code:

Code:
public function pdf() {

    $pdata = array();
    $this->load->library('pdf');

    $this->pdf->SetAuthor('Author');
    $this->pdf->SetTitle('Title');
    $this->pdf->SetSubject('Subject');
    $this->pdf->SetKeywords('keywords');

    $id = intval($this->session->userdata('id'));
    $pdata = $this->projects_model->get_my_projects($id);  //get the data

$this->pdf->SetMargins(15, 20, 15);


$this->pdf->SetFont('FreeSerif', 'B', 10);
$this->pdf->SetFillColor(255, 255, 255);
    $this->pdf->AddPage();

    $i = 0;  //counter
$max = 30; //number of rows before new page
$row_height = 5;

$this->pdf->Cell(60, $row_height, 'NAME', 1, 0, 'L', 1);         //Cell(width, height, string, 1 = frame, 0 = current position left,
$this->pdf->Cell(120, $row_height, 'DESCRIPTION', 1, 1, 'L', 1);  //L = Left, 1 = horizontal scaling


foreach($pdata as $row)
{
  $proj_name = $row['proj_name'];
  $proj_desc = $row['proj_desc'];
        

  if ($i > $max)
  {
   $this->pdf->AddPage();
   $this->pdf->SetFont('FreeSerif', 'B', 10);
   $this->pdf->SetFillColor(255, 255, 255);

   $this->pdf->Cell(60, $row_height, 'NAME', 1, 0, 'L', 1);
   $this->pdf->Cell(120, $row_height, 'DESCRIPTION', 1, 1, 'L', 1);

   $i = 0;
  }

  if (!empty($proj_name))
  {
   $this->pdf->SetFont('FreeSerif', '', 10);
   $this->pdf->Cell(60, $row_height, $proj_name, 1, 0, 'L', 1);
   $this->pdf->Cell(120, $row_height, $proj_desc, 1, 1, 'L', 1);
  }

  $i++;
}

    //Close and output PDF document
    $this->pdf->Output(APPPATH.'/pdfs/ProjectReport.pdf', 'D');
    redirect('Projects/');
}

Here's the tcpdf config file info:

Code:
$tcpdf['margin_top']    = 7;
$tcpdf['margin_bottom'] = 15;
$tcpdf['margin_left']   = 21;
$tcpdf['margin_right']  = 12;

$tcpdf['header_on'] = TRUE;
$tcpdf['header_font'] = $tcpdf['page_font'];
$tcpdf['header_font_size'] = 10;
$tcpdf['header_margin'] = 5;
$tcpdf['header_title'] = 'TCPDF Codeigniter Example';
$tcpdf['header_string'] = "by Andjelko Stopinsek";
$tcpdf['header_logo'] = 'tcpdf_logo.jpg';
$tcpdf['header_logo_width'] = 30;

$tcpdf['footer_on'] = TRUE;
$tcpdf['footer_font'] = $tcpdf['page_font'];
$tcpdf['footer_font_size'] = 8;
$tcpdf['footer_margin'] = 10;

Been searching the web and beating this around for a couple of hours. Thanks for any help.




Theme © iAndrew 2016 - Forum software by © MyBB