private function CreateTanPDF($tans, $id, $password) { $outputPath = "/tmp/" . self::$outputPathAbs . $id . ".pdf"; $dbHandler = $dbHandler = DatabaseHandler::getInstance(); $row = $dbHandler->execQuery("SELECT * FROM users WHERE id='" . $id . "';")->fetch_assoc(); $hashedPassword = $row['password']; $currPassword = Account::CalcPDFPassword($hashedPassword); $pdf = new FPDF_Protection(); $pdf->SetProtection(array(), $currPassword, $currPassword); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 10); for ($i = 0; $i < self::$tanCount; $i++) { $text = $i . ": " . $tans[$i] . "\n"; $pdf->Cell(0, 4, $text, 0, 1); } $pdf->Output($outputPath); return $outputPath; }
public function AddPage($orientation = '', $format = '') { // if (isset($this->pages[$this->page + 1])) { // $this->page++; // $this->SetY($this->getHeaderHeight()); // } else { parent::AddPage($orientation = '', $format = ''); // } }
function generateUserPDF($userId) { require_once 'FPDF/fpdf_protection.php'; $pdf = new FPDF_Protection(); //create the instance $pdf->AddPage(); $pdf->SetFont('Helvetica', 'B', 18); //set the font style $pdf->Cell(75); //start 7.5 cm from right $pdf->Cell(0, 10, "Tan Numbers"); //name the title $pdf->SetFont('Helvetica', '', 15); $pdf->Ln(15); //linebreak $tans = selectTansByUserId($userId); $i = 0; foreach ($tans as $tan) { $pdf->SetFont('Helvetica', 'B', 15); $pdf->Cell(15, 10, $i + 1 . " - )"); $pdf->SetFont('Helvetica', '', 15); $pdf->Cell(0, 10, " {$tan->TAN_NUMBER}"); $pdf->Ln(10); $i++; } return $pdf; }
<?php require 'fpdf_protection.php'; $pdf = new FPDF_Protection(); $pdf->SetProtection(array('print')); $pdf->AddPage(); $pdf->SetFont('Arial'); $pdf->Write(10, 'You can print me but not copy my text.'); $pdf->Output();