From e67ef53047e073048577ad69f394e0d86cfedafb Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Tue, 4 Aug 2020 01:23:18 +0100 Subject: [PATCH] Use correct pdf package to generate pdf file on invoice download/email activity --- CRM/Contribute/Form/Task/Invoice.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index d189158cd8..b85c1b185b 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -479,7 +479,11 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 'metric' => 'px', ]); // functions call for adding activity with attachment - $fileName = self::putFile($html, $pdfFileName); + $fileName = self::putFile($html, $pdfFileName, [ + 'margin_top' => 10, + 'margin_left' => 65, + 'metric' => 'px', + ]); self::addActivities($subject, $contactIds, $fileName, $params); CRM_Utils_System::civiExit(); @@ -554,22 +558,13 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { * Content for pdf in html format. * * @param string $name + * @param array $format * * @return string * Name of file which is in pdf format */ - public static function putFile($html, $name = 'Invoice.pdf') { - $options = new Options(); - $options->set('isRemoteEnabled', TRUE); - - $doc = new DOMPDF($options); - $doc->load_html($html); - $doc->render(); - $html = $doc->output(); - $config = CRM_Core_Config::singleton(); - $fileName = $config->uploadDir . $name; - file_put_contents($fileName, $html); - return $fileName; + public static function putFile($html, $name = 'Invoice.pdf', $format = NULL) { + return CRM_Utils_Mail::appendPDF($name, $html, $format)['fullPath'] ?? ''; } /** -- 2.25.1