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; }
//actual position $x = $pdf->GetX(); $y = $pdf->GetY(); //Draw $pdf->Rect($x, $y, $w, $h); //Write $pdf->MultiCell($w, 5, stripslashes($record[$table[$i]]), 0, $a); //go to right $pdf->SetXY($x + $w, $y); } //return to line $pdf->Ln($h); } $pdf_file = "print_out_pdf_" . date("Y-m-d", mktime(0, 0, 0, date('m'), date('d'), date('y'))) . "_" . generateKey() . ".pdf"; //send the file $pdf->Output($_SESSION['settings']['path_to_files_folder'] . "/" . $pdf_file); //log logEvents('pdf_export', "", $_SESSION['user_id'], $_SESSION['login']); //clean table DB::query("TRUNCATE TABLE " . prefix_table("export")); echo '[{"text":"<a href=\'' . $_SESSION['settings']['url_to_files_folder'] . '/' . $pdf_file . '\' target=\'_blank\'>' . $LANG['pdf_download'] . '</a>"}]'; } break; //CASE export in CSV format //CASE export in CSV format case "export_to_csv_format": $full_listing = array(); $full_listing[0] = array('id' => "id", 'label' => "label", 'description' => "description", 'pw' => "pw", 'login' => "login", 'restricted_to' => "restricted_to", 'perso' => "perso"); $id_managed = ''; $i = 1; $items_id_list = array();
<?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();