Jump to content

HTML2FPDF - Criação de Header e Footer de um arquivo em pdf


Demoins
 Share

Recommended Posts

Alguém sabe e pode me explicar como colocar o header e footer utilizando a class HTML2FPDF?

eu tento assim:

class pdf extends html2fpdf {
	function Header() {
			//  Logo
			$this -> Image('../images/logo.gif',10,10,33);
			//   Arial bold 15
		    $this -> SetFont('Arial','B',13);
			//Calculate width of title and position
			$w = $this->GetStringWidth($title)+6;
			$this -> SetX((210-$w)/2); 
			//   Move to the right
			//  $this->Cell(80);
			//   Title
		    $this -> Cell($w,9,$title,0,0,'C',1); 
			//   Line break
		    $this -> Ln(20);
	}

	function Footer() {
		//To be implemented in your own inherited class
		//   Position at 1.5 cm from bottom
	    $this -> SetY(-15);
		//  Arial italic 8
	    $this -> SetFont('Arial','I',8);
		//  Page number
	    $this -> Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
	}
}

$pdf = new html2fpdf();
$pdf -> AliasNbPages();
$pdf -> AddPage();
$pdf -> SetFont('Arial', '', 12);
        $line = '<table id="comp_portfolio">
		<tr>
			<td align="left" colspan="2">
				<h4>Título</h4>
			</td>
		</tr>
		<tr>
			<td>
				item
			</td>
			<td>
				Descrição
			</td>
			</tr>
		</table>';
        $pdf -> writehtml($line);
$pdf -> Output('List.pdf', 'D');

mas o problema é que não acontece nada :S

Se me pudessem ajudar, agradecia 😉

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.