protected function ConvertToPdf::applyProperties in PDF using mPDF 8
Same name and namespace in other branches
- 8.2 src/Conversion/ConvertToPdf.php \Drupal\pdf_using_mpdf\Conversion\ConvertToPdf::applyProperties()
Apply additional properties to PDF file.
1 call to ConvertToPdf::applyProperties()
- ConvertToPdf::generator in src/
Conversion/ ConvertToPdf.php - Generate the PDF file using the Mpdf library.
File
- src/
Conversion/ ConvertToPdf.php, line 184
Class
- ConvertToPdf
- Class ConvertToPdf.
Namespace
Drupal\pdf_using_mpdf\ConversionCode
protected function applyProperties() {
// Set Watermark.
$watermark_option = $this->settings['watermark_option'];
$watermark_opacity = $this->settings['watermark_opacity'];
if ($watermark_option == 0) {
$text = $this->settings['pdf_watermark_text'];
if (!empty($text)) {
$this->mpdf
->SetWatermarkText($text, $watermark_opacity);
$this->mpdf->showWatermarkText = TRUE;
}
}
else {
$image_id = $this->settings['watermark_image'];
if (isset($image_id[0])) {
$file = File::load($image_id[0]);
$image_path = $file
->getFileUri();
$image_path = file_create_url($image_path);
$this->mpdf
->SetWatermarkImage($image_path, $watermark_opacity);
$this->mpdf->showWatermarkImage = TRUE;
}
}
// Set Title.
$title = $this->settings['pdf_set_title'];
if (!empty($title)) {
$this->mpdf
->SetTitle($title);
}
// Set Author.
$author = $this->settings['pdf_set_author'];
if (!empty($author)) {
$this->mpdf
->SetAuthor($author);
}
// Set Subject.
$subject = $this->settings['pdf_set_subject'];
if (isset($subject) && $subject != NULL) {
$this->mpdf
->SetSubject($subject);
}
// Set Creator.
$creator = $this->settings['pdf_set_creator'];
if (!empty($creator)) {
$this->mpdf
->SetCreator($creator);
}
// Set Password.
$password = $this->settings['pdf_password'];
if (!empty($password)) {
$this->mpdf
->SetProtection([
'print',
'copy',
], $password, $password);
}
}