class DocRaptorPDF in Forena Reports 8
Provides PDF file exports using Doc Raptor PDF Generation Service
Plugin annotation
@FrxDocument(
id= "pdf-docraptor",
name="PDF Generation using Doc Raptor web services",
ext="pdf"
)
Hierarchy
- class \Drupal\forena\FrxPlugin\Document\DocumentBase implements DocumentInterface uses FrxAPI
- class \Drupal\forena_pdf\FrxPlugin\Document\DocRaptorPDF
Expanded class hierarchy of DocRaptorPDF
File
- forena_pdf/
src/ FrxPlugin/ Document/ DocRaptorPDF.php, line 19 - PrincePDF
Namespace
Drupal\forena_pdf\FrxPlugin\DocumentView source
class DocRaptorPDF extends DocumentBase {
private $docraptor_key;
private $docraptor_url;
private $docraptor_test;
public function __construct() {
$this->content_type = 'application/pdf';
$config = \Drupal::config('forena_pdf.settings');
$this->docraptor_key = $config
->get('docraptor_key');
$this->docraptor_url = $config
->get('docraptor_url');
$this->docraptor_test = $config
->get('docraptor_test');
}
public function flush() {
$options = [];
$css = '';
$disable_links = \Drupal::config('forena.pdf.settings')
->get('disable_links');
$html = $this->write_buffer;
if ($disable_links) {
$html = preg_replace('/<a href=\\"(.*?)\\">(.*?)<\\/a>/', "\\2", $html);
}
$link_class = $disable_links ? 'prince-disable-links' : '';
$output = '<html><head>';
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>';
if (isset($options['css']) || isset($r->rpt_xml->head->style)) {
$output .= '<style type="text/css">';
$output .= $css;
if (isset($r->rpt_xml->head->style) || isset($r->rpt_xml->head->style)) {
$sheet = (string) $r->rpt_xml->head->style;
$output .= $sheet;
}
$output .= '</style>';
}
$output .= '<title>' . $this->title . "</title></head><body class='forena-report {$link_class}'><h1>" . $this->title . '</h1>' . $html . '</body></html>';
$api_key = $this->docraptor_key;
if ($api_key) {
$service_url = $this->docraptor_url;
$url = "{$service_url}?user_credentials={$api_key}";
$name = 'report.pdf';
$post_array = array(
'doc[name]' => $name,
'doc[document_type]' => 'pdf',
'doc[test]' => $this->docraptor_test ? 'true' : 'false',
'doc[document_content]' => $output,
);
$postdata = http_build_query($post_array);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata,
),
);
$context = stream_context_create($opts);
$doc = file_get_contents($url, false, $context);
return $doc;
}
else {
drupal_set_message(t('No Docraptor API Key Configured'), 'error');
return '';
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DocRaptorPDF:: |
private | property | ||
DocRaptorPDF:: |
private | property | ||
DocRaptorPDF:: |
private | property | ||
DocRaptorPDF:: |
public | function |
Write the output to disk. Overrides DocumentBase:: |
|
DocRaptorPDF:: |
public | function | ||
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 |
No default footer. Overrides DocumentInterface:: |
1 |
DocumentBase:: |
public | function | ||
DocumentBase:: |
public | function |
Default implementation to put in content type based headers. Overrides DocumentInterface:: |
8 |
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. |