1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
<?php
use setasign\Fpdi\Fpdi;
require_once('Fpdf/fpdf.php');
require_once('Fpdi/src/autoload.php');
// initiate FPDI
$texte ="Ici il y aura le nom de l'élève. M. Tatenpion" ;
$nom_eleve="Nom de l'élève";
$fullPathToFile = "Relance.pdf";
class PDF_Rotate extends FPDI {
var $angle = 0;
function Rotate($angle, $x = -1, $y = -1) {
if ($x == -1)
$x = $this->x;
if ($y == -1)
$y = $this->y;
if ($this->angle != 0)
$this->_out('Q');
$this->angle = $angle;
if ($angle != 0) {
$angle*=M_PI/180;
$c = cos($angle);
$s = sin($angle);
$cx = $x * $this->k;
$cy = ($this->h - $y) * $this->k;
$this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
}
}
function _endpage() {
if ($this->angle != 0) {
$this->angle = 0;
$this->_out('Q');
}
parent::_endpage();
}
}
class PDF extends PDF_Rotate {
var $_tplIdx;
function Header() {
global $fullPathToFile;
global $texte;
global $nom_eleve;
//Put the watermark
//$this->Image("photo_eleve.jpg", 10, 10, 26, 29, 'jpg'); //[0] = how much right, [1] = the less, the higher.
$this->SetFont('Arial', 'B', 30);
$this->SetTextColor(255, 192, 203);
$this->RotatedText(20, 230,$texte, 45);
if (is_null($this->_tplIdx)) {
// THIS IS WHERE YOU GET THE NUMBER OF PAGES
$this->numPages = $this->setSourceFile($fullPathToFile);
$this->_tplIdx = $this->importPage(1);
$this->SetFont('Arial', '', 12);
$this->SetTextColor(255, 0, 0);
$this->SetXY(10, 45);
$this->Write(0, $nom_eleve);
$this->Image("photo_eleve.jpg", 10, 10, 26, 29, 'jpg'); //[0] = how much right, [1] = the less, the higher.
$this->useTemplate($this->_tplIdx, 0, 0, 200);
}
$this->useTemplate($this->_tplIdx, 0, 0, 200);
}
function RotatedText($x, $y, $txt, $angle) {
//Text rotated around its origin
$this->Rotate($angle, $x, $y);
$this->Text($x, $y, $txt);
$this->Rotate(0);
}
}
# ==========================
$pdf = new PDF();
//$pdf = new FPDI();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);
/*
$txt = "FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say " .
"without using the PDFlib library. F from FPDF stands for Free: you may use it for any " .
"kind of usage and modify it to suit your needs.\n\n";
for ($i = 0; $i < 25; $i++) {
$pdf->MultiCell(0, 5, $txt, 0, 'J');
}
*/
if($pdf->numPages>1) {
for($i=2;$i<=$pdf->numPages;$i++) {
//$pdf->endPage();
$pdf->_tplIdx = $pdf->importPage($i);
$pdf->AddPage();
}
}
$pdf->Output();
?> |
Partager