Hi Abu, I am trying to output the logged in users name in the PDF header but cant seem to find a way to achieve it.. I use throughout the site to out users name, is the below in wrong format?
$opt["export"] = array("format"=>"pdf", "filename"=>"Adviser Monthly Invoice", "heading"=> '<?php echo userValue($_SESSION['uid'], "username"); ?>', "orientation"=>"landscape", "paper"=>"a4");
Thank you
I tested this case and works as expected.
$_SESSION["uid"] = "Abu Ghufran";
$grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "heading"=>"Invoice Details: ".$_SESSION["uid"], "orientation"=>"landscape", "paper"=>"a4");
Sample Code: http://pastebin.com/HMDA3FAr
Output PDF: http://easycaptures.com/0115674286
Thanks Abu, that's an odd one, if I output <?php echo userValue($_SESSION['uid'], "username"); ?> in my page it displays Gary Brett, however if I use
$opt["export"] = array("format"=>"pdf", "filename"=>"Adviser Monthly Invoice", "heading"=>"Invoice Details: ".$_SESSION["uid"],"username", "orientation"=>"landscape", "paper"=>"a4");
it ouputs the number 3 which is my id in the users table, seems its ignoring the "username" code..
Forgot to ask, your outputted pdf table looks nice with single table border and blue header, is that all done inside tcpdf?
It looks to be the code logic on your end. PDF header is set with whatever you pass in 'heading' option.
The colors can be set using on_render_pdf handler: See the Code link: http://pastebin.com/HMDA3FAr
$pdf->SetHeaderCellsFillColor(30,70,99);
$pdf->SetHeaderCellsFontColor(255,255,255);
To increase pdf header font size, i changed:
$pdf->Cell( 0, 15, $this->options["export"]["heading"], 0, 1 );
with
$pdf->SetFont('helvetica', '', 15);
$pdf->SetHeaderCellsFontStyle('b');
$pdf->Cell( 0, 15, $this->options["export"]["heading"], 0, 1 );
$pdf->SetFont('helvetica', '', 12);
Hi, looking at it a different way, could we include a column from the grid in the 'heading'?
$col["name"] = "adviser" + $col["name"] = "date_paid"
This would then output Invoice Details: Gary Brett 01.05.15
Thank you
Fixed original query if it helps anyone –
$username = userValue($_SESSION['uid'], "username");
$opt["export"] = array("format"=>"pdf", "filename"=>"Adviser Monthly Invoice", "heading"=>"Invoice Details: ". $username, "orientation"=>"landscape", "paper"=>"a4");