X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FPDF%2FUtils.php;h=9f103d72a8ca1857fcf02e48ed146981d2cedfeb;hb=50bfb46054c0ccd0f836a569c5417969da3c1a53;hp=93337e7bb94af15df6fd0c8427a8d8d2141aa98c;hpb=b96b0678fc5341bb1c30595462c29d3d7a47729c;p=civicrm-core.git diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index 93337e7bb9..9f103d72a8 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -33,8 +33,6 @@ define('DOMPDF_ENABLE_AUTOLOAD', FALSE); * * @package CRM * @copyright CiviCRM LLC (c) 2004-2015 - * $Id$ - * */ class CRM_Utils_PDF_Utils { @@ -305,120 +303,4 @@ class CRM_Utils_PDF_Utils { return $value; } - /** - * @param string $fileName - * @param $searchPath - * @param $values - * @param int $numPages - * @param bool $echo - * @param string $output - * @param string $creator - * @param string $author - * @param string $title - */ - public static function &pdflib( - $fileName, - $searchPath, - &$values, - $numPages = 1, - $echo = TRUE, - $output = 'College_Match_App', - $creator = 'CiviCRM', - $author = 'http://www.civicrm.org/', - $title = '2006 College Match Scholarship Application' - ) { - try { - $pdf = new PDFlib(); - $pdf->set_parameter("compatibility", "1.6"); - $pdf->set_parameter("licensefile", "/home/paras/bin/license/pdflib.txt"); - - if ($pdf->begin_document('', '') == 0) { - CRM_Core_Error::statusBounce("PDFlib Error: " . $pdf->get_errmsg()); - } - - $config = CRM_Core_Config::singleton(); - $pdf->set_parameter('resourcefile', $config->templateDir . '/Quest/pdf/pdflib.upr'); - $pdf->set_parameter('textformat', 'utf8'); - - /* Set the search path for fonts and PDF files */ - - $pdf->set_parameter('SearchPath', $searchPath); - - /* This line is required to avoid problems on Japanese systems */ - - $pdf->set_parameter('hypertextencoding', 'winansi'); - - $pdf->set_info('Creator', $creator); - $pdf->set_info('Author', $author); - $pdf->set_info('Title', $title); - - $blockContainer = $pdf->open_pdi($fileName, '', 0); - if ($blockContainer == 0) { - CRM_Core_Error::statusBounce('PDFlib Error: ' . $pdf->get_errmsg()); - } - - for ($i = 1; $i <= $numPages; $i++) { - $page = $pdf->open_pdi_page($blockContainer, $i, ''); - if ($page == 0) { - CRM_Core_Error::statusBounce('PDFlib Error: ' . $pdf->get_errmsg()); - } - - /* dummy page size */ - $pdf->begin_page_ext(20, 20, ''); - - /* This will adjust the page size to the block container's size. */ - - $pdf->fit_pdi_page($page, 0, 0, 'adjustpage'); - - $status = array(); - /* Fill all text blocks with dynamic data */ - - foreach ($values as $key => $value) { - if (is_array($value)) { - continue; - } - - // pdflib does like the forward slash character, hence convert - $value = str_replace('/', '_', $value); - - $res = $pdf->fill_textblock($page, - $key, - $value, - 'embedding encoding=winansi' - ); - - } - - $pdf->end_page_ext(''); - $pdf->close_pdi_page($page); - } - - $pdf->end_document(''); - $pdf->close_pdi($blockContainer); - - $buf = $pdf->get_buffer(); - $len = strlen($buf); - - if ($echo) { - CRM_Utils_System::setHttpHeader('Content-type', 'application/pdf'); - CRM_Utils_System::setHttpHeader("Content-Length", $len); - CRM_Utils_System::setHttpHeader("Content-Disposition", "inline; filename={$output}.pdf"); - echo $buf; - CRM_Utils_System::civiExit(); - } - else { - return $buf; - } - } - catch (PDFlibException$excp) { - CRM_Core_Error::statusBounce('PDFlib Error: Exception' . - "[" . $excp->get_errnum() . "] " . $excp->get_apiname() . ": " . - $excp->get_errmsg() - ); - } - catch (Exception$excp) { - CRM_Core_Error::statusBounce("PDFlib Error: " . $excp->get_errmsg()); - } - } - }