You are here

public function MpdfGenerator::setPassword in PDF generator API 8

Same name and namespace in other branches
  1. 2.x src/Plugin/PdfGenerator/MpdfGenerator.php \Drupal\pdf_api\Plugin\PdfGenerator\MpdfGenerator::setPassword()

Sets the password in PDF.

Parameters

string $password: The password which will be used in PDF.

File

src/Plugin/PdfGenerator/MpdfGenerator.php, line 138
Contains \Drupal\pdf_api\Plugin\MpdfGenerator.

Class

MpdfGenerator
A PDF generator plugin for the mPDF library.

Namespace

Drupal\pdf_api\Plugin\PdfGenerator

Code

public function setPassword($password) {
  if (isset($password) && $password != NULL) {

    // Print and Copy is allowed.
    $this->generator
      ->SetProtection(array(
      'print',
      'copy',
    ), $password, $password);
  }
}