| 123456789101112131415161718192021222324252627282930313233343536 | 
							- <?php
 
- require_once(__DIR__.SLASH.'HtmlExport.class.php');
 
- class PdfExport extends HtmlExport{
 
- 	public static $mime = 'application/pdf';
 
- 	public static $extension = 'pdf';
 
- 	public static $description = 'Fichier informations PDF';
 
- 	public static function sample($dataset){
 
- 		$stream = parent::sample($dataset);
 
- 		$pdf = new Pdf($stream);
 
- 		$stream = $pdf->generate();
 
- 		return $stream;
 
- 	}
 
- 	public static function from_template($source, $data, $return, $isHtml=true){
 
- 		$htmlRaw = HtmlExport::from_template($source, $data, $return, $isHtml);
 
- 		$stream = $return=='stream' ? $htmlRaw : file_get_contents($htmlRaw);
 
- 	    $pdf = new Pdf($stream);
 
- 	    $pdfStream = $pdf->generate();
 
- 	    $destination = File::dir().'tmp'.SLASH.'template.'.time().'-'.rand(0,100).'.pdf';
 
- 	    file_put_contents($destination, $pdfStream);
 
- 	    if($return!='stream') {
 
- 	    	unlink($htmlRaw);
 
- 	    	return $destination;
 
- 	    }
 
- 	    
 
- 	    $stream = file_get_contents($destination);
 
- 		unlink($destination);
 
- 	    return $stream;
 
- 	}
 
- }
 
- ?>
 
 
  |