base64 images pdf

This commit is contained in:
Daniel Barbero 2019-12-12 14:01:11 +01:00
parent ab1c6e17ca
commit 415a54fb55
3 changed files with 147 additions and 99 deletions

View File

@ -3570,6 +3570,7 @@ function agents_get_network_interfaces_array(
'server_id' => $id_meta,
'height' => $config['graph_image_height'],
'landscape' => $content['landscape'],
'return_img_base_64' => true,
];
$params_combined = [
@ -3581,11 +3582,21 @@ function agents_get_network_interfaces_array(
case 'dinamic':
case 'static':
if (!empty($interface['traffic'])) {
if ($pdf === false) {
$row_interface['chart'] = graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
} else {
$row_interface['chart'] = '<img src="data:image/jpg;base64,';
$row_interface['chart'] .= graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
$row_interface['chart'] .= '" />';
}
}
break;
@ -4572,18 +4583,28 @@ function reporting_projection_graph(
'server_id' => $id_meta,
'height' => $config['graph_image_height'],
'landscape' => $content['landscape'],
'return_img_base_64' => true,
];
$params_combined = [
'projection' => $content['top_n_value'],
];
if ($pdf === true) {
$return['chart'] = '<img src="data:image/jpg;base64,';
$return['chart'] .= graphic_combined_module(
[$content['id_agent_module']],
$params,
$params_combined
);
$return['chart'] .= '" />';
} else {
$return['chart'] = graphic_combined_module(
[$content['id_agent_module']],
$params,
$params_combined
);
}
break;
case 'data':
@ -4830,6 +4851,7 @@ function reporting_value($report, $content, $type, $pdf=false)
'height' => $config['graph_image_height'],
'fullscale' => true,
'landscape' => $content['landscape'],
'return_img_base_64' => true,
];
switch ($type) {
@ -4895,7 +4917,12 @@ function reporting_value($report, $content, $type, $pdf=false)
];
if ($content['visual_format'] != 1) {
if ($only_image === false) {
$graph = grafico_modulo_sparse($params);
} else {
$graph = '<img src="data:image/jpg;base64,'.grafico_modulo_sparse($params).'" />';
}
$return['data'][] = ['value' => $graph];
}
@ -7608,6 +7635,7 @@ function reporting_custom_graph(
'server_id' => $id_meta,
'height' => $config['graph_image_height'],
'landscape' => $content['landscape'],
'return_img_base_64' => true,
];
$params_combined = [
@ -7620,12 +7648,21 @@ function reporting_custom_graph(
'labels' => $content['style']['label'],
];
if ($pdf === true) {
$return['chart'] = '<img src="data:image/jpg;base64,';
$return['chart'] .= graphic_combined_module(
$modules,
$params,
$params_combined
);
$return['chart'] .= '" />';
} else {
$return['chart'] = graphic_combined_module(
$modules,
$params,
$params_combined
);
}
break;
case 'data':
@ -7789,9 +7826,14 @@ function reporting_simple_graph(
'server_id' => $id_meta,
'height' => $config['graph_image_height'],
'landscape' => $content['landscape'],
'return_img_base_64' => true,
];
if ($only_image === false) {
$return['chart'] = grafico_modulo_sparse($params);
} else {
$return['chart'] = '<img src="data:image/jpg;base64,'.grafico_modulo_sparse($params).'" />';
}
break;
case 'data':

View File

@ -778,9 +778,14 @@ function flot_slicesbar_graph(
'ttl' => 1,
'widgets' => $widgets,
'show' => $show,
'return_img_base_64' => true,
];
return generator_chart_to_pdf('slicebar', $params);
$graph = '<img src="data:image/jpg;base64,';
$graph .= generator_chart_to_pdf('slicebar', $params);
$graph .= '" />';
return $graph;
}
// Get a unique identifier to graph

View File

@ -94,7 +94,8 @@ page.onCallback = function() {
if (!base_64) {
page.render(output_filename, { format: "png" });
} else {
var base64 = page.renderBase64("png");
page.settings.loadImages = false;
var base64 = page.renderBase64("jpg");
// do not remove this console.output
console.log(base64);
}