- permissions is an array with values taken from the following list:
copy, print, modify, annot-forms
If a value is present it means that the permission is granted
- If a user password is set, user will be prompted before document is opened
- If an owner password is set, document can be opened in privilege mode with no
restriction if that password is entered
public SetProtection ( $permissions = [], $user_pass = '', $owner_pass = null ) |
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; }
break; case "finalize_export_pdf": // query $rows = DB::query("SELECT * FROM " . prefix_table("export")); $counter = DB::count(); if ($counter > 0) { // print //Some variables $table_full_width = 190; $table_col_width = array(45, 40, 45, 60); $table = array('label', 'login', 'pw', 'description'); $prev_path = ""; //Prepare the PDF file include $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Pdf/Tfpdf/fpdf.php'; $pdf = new FPDF_Protection(); $pdf->SetProtection(array('print'), $_POST['pdf_password']); //Add font for regular text $pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.ttf', true); //Add monospace font for passwords $pdf->AddFont('LiberationMono', ''); $pdf->aliasNbPages(); $pdf->addPage(); $pdf->SetFont('DejaVu', '', 16); $pdf->Cell(0, 10, $LANG['print_out_pdf_title'], 0, 1, 'C', false); $pdf->SetFont('DejaVu', '', 12); $pdf->Cell(0, 10, $LANG['pdf_del_date'] . " " . date($_SESSION['settings']['date_format'] . " " . $_SESSION['settings']['time_format'], time()) . ' ' . $LANG['by'] . ' ' . $_SESSION['login'], 0, 1, 'C', false); $prev_path = ""; $table = array('label', 'login', 'pw', 'description'); foreach ($rows as $record) { $printed_ids[] = $record['id']; if ($prev_path != $record['path']) {
<?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();