class MPDF in Forena Reports 8
@TODO: Determine the viability of keeping this given the troubles with MPDF.
The mPDF distributuion is current in an unknown state. s
Class MPDF @package Drupal\forena_pdf\FrxPlugin\Document
Hierarchy
- class \Drupal\forena\FrxPlugin\Document\DocumentBase implements DocumentInterface uses FrxAPI
Expanded class hierarchy of MPDF
1 string reference to 'MPDF'
- forena_pdf_configure in forena_pdf/
forena_pdf.module - Implementation of configuration form.
File
- forena_pdf/
src/ FrxPlugin/ Document/ MPDF.php, line 22 - MPDF.inc PDF document via MPDF Library @author davidmetzler
Namespace
Drupal\forena_pdf\FrxPlugin\DocumentView source
class MPDF extends DocumentBase {
use FrxAPI;
private $p;
public function __construct() {
// To do - use config variable of path to mpdf libs
define('_MPDF_PATH', 'libraries/mpdf/');
include_once 'libraries/mpdf/mpdf.php';
$this->content_type = 'application/pdf';
}
public function header($r, $print = TRUE) {
$r->html = '';
}
public function render($r, $format, $options = array()) {
// To Do
// The option switch off links on PDF will bee good here too
$disable_links = \Drupal::config('forena_pdf.settings')
->get('disable_links');
$skin_data = $this
->getDataContext('skin');
$page_data = isset($skin_data['mpdf']['page']) ? $skin_data['mpdf']['page'] : array(
'orientation' => 'P',
);
$html = $this
->check_markup($r->html);
if ($disable_links) {
$html = preg_replace('/<a href=\\"(.*?)\\">(.*?)<\\/a>/', "\\2", $html);
}
$mpdf = new mPDF('UTF-8');
$mpdf
->AddPageByArray($page_data);
$output = '';
$output = '<html><head>';
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>';
if (!empty($options['css']) || isset($r->rpt_xml->head->style)) {
$output .= '<style type="text/css">';
$output .= $css;
if (isset($r->rpt_xml->head->style)) {
$sheet = (string) $r->rpt_xml->head->style;
$output .= $sheet;
}
$output .= '</style>';
}
$output .= '<title>' . $r->title . "</title></head><body class='forena-report {$link_class}'><h1>" . $r->title . '</h1>' . $html;
$output .= '</body></html>';
foreach ($this
->getDocument()->stylesheets as $type => $sheets) {
foreach ($sheets as $sheet) {
switch ($type) {
case 'all':
case 'print':
case 'screen':
case 'pdf':
$mpdf
->WriteHTML(file_get_contents($sheet), 1);
//echo $sheet;
break;
}
}
}
$mpdf
->WriteHTML($output);
// $pdf = $mpdf->Output('', 'S');
$pdf = $mpdf
->output();
return $pdf;
}
public function output(&$output) {
$http_headers = array(
'Pragma' => 'no-cache',
'Expires' => '0',
'Cache-Control' => 'no-cache, must-revalidate',
'Content-Transfer-Encoding' => 'binary',
'Content-Type' => 'application/pdf',
);
foreach ($http_headers as $name => $value) {
$value = preg_replace('/\\r?\\n(?!\\t| )/', '', $value);
drupal_add_http_header($name, $value);
}
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | property | ||
DocumentBase:: |
protected | property | ||
DocumentBase:: |
public | function | ||
DocumentBase:: |
public | function | Wrapper function for check output to default the right type. | |
DocumentBase:: |
public | function |
Clear the buffer Overrides DocumentInterface:: |
|
DocumentBase:: |
public | function | Perform character set conversion | |
DocumentBase:: |
public | function |
Write the output to disk. Overrides DocumentInterface:: |
9 |
DocumentBase:: |
public | function |
No default footer. Overrides DocumentInterface:: |
1 |
DocumentBase:: |
public | function | ||
DocumentBase:: |
public | function |
Overrides DocumentInterface:: |
|
DocumentBase:: |
public | function |
Overrides DocumentInterface:: |
|
DocumentBase:: |
public | function |
Write Overrides DocumentInterface:: |
|
FrxAPI:: |
public | function | Returns containing application service | |
FrxAPI:: |
public | function | Get the current data context. | |
FrxAPI:: |
public | function | ||
FrxAPI:: |
public | function | Returns the data manager service | |
FrxAPI:: |
public | function | Return Data Service | |
FrxAPI:: |
public | function | Returns the fornea document manager | |
FrxAPI:: |
public | function | Report an error | |
FrxAPI:: |
public | function | Get the context of a specific id. | |
FrxAPI:: |
public | function | Get the current document | |
FrxAPI:: |
public | function | Load the contents of a file in the report file system. | |
FrxAPI:: |
function | Enter description here... | 1 | |
FrxAPI:: |
public | function | Pop data off of the stack. | |
FrxAPI:: |
public | function | Push data onto the Stack | |
FrxAPI:: |
public | function | Run a report with a particular format. | 1 |
FrxAPI:: |
public | function | Get the current report file system. | |
FrxAPI:: |
public | function | Set Data context by id. | |
FrxAPI:: |
public | function | Change to a specific document type. | |
FrxAPI:: |
public | function | Get list of skins. | |
MPDF:: |
private | property | ||
MPDF:: |
public | function |
Default implementation to put in content type based headers. Overrides DocumentBase:: |
|
MPDF:: |
public | function | ||
MPDF:: |
public | function | ||
MPDF:: |
public | function |