Php 海图不';是否将查看页面上的外部图像转换为pdf?
我已经将html数据和高图转换为pdf,但每当我使用外部图像时,它不会将该图像转换为pdf,我使用了以下代码,但它只将高图转换为pdf而不是图像Php 海图不';是否将查看页面上的外部图像转换为pdf?,php,codeigniter,Php,Codeigniter,我已经将html数据和高图转换为pdf,但每当我使用外部图像时,它不会将该图像转换为pdf,我使用了以下代码,但它只将高图转换为pdf而不是图像 Highcharts.getSVG = function (charts) { var svgArr = [], top = 0, width = 0; $.each(charts, function (i, chart) { var svg = chart.getSVG
Highcharts.getSVG = function (charts) {
var svgArr = [],
top = 0,
width = 0;
$.each(charts, function (i, chart) {
var svg = chart.getSVG();
svg = svg.replace('<svg', '<g transform="translate(0,' + top + ')" ');
svg = svg.replace('</svg>', '</g>');
top += chart.chartHeight;
width = Math.max(width, chart.chartWidth);
svgArr.push(svg);
});
return '<svg height="' + top + '" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>';
};
Highcharts.exportCharts = function (charts, options) {
var form
svg = Highcharts.getSVG(charts);
// merge the options
options = Highcharts.merge(Highcharts.getOptions().exporting, options);
// create the form
form = Highcharts.createElement('form', {
method: 'post',
action: options.url
}, {
display: 'none'
}, document.body);
// add the values
Highcharts.each(['filename', 'type', 'width', 'svg'], function (name) {
Highcharts.createElement('input', {
type: 'hidden',
name: name,
value: {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: svg
}[name]
}, null, form);
});
form.submit();
form.parentNode.removeChild(form);
};
Highcharts.getSVG=函数(图表){
var svgArr=[],
top=0,
宽度=0;
$。每个(图表、函数(i、图表){
var svg=chart.getSVG();
svg=svg.replace(“
.集装箱{
最大宽度:600px;
最小宽度:320px;
保证金:0自动;
}
#按钮箭头{
最大宽度:600px;
最小宽度:320px;
保证金:0自动;
}
/**
*创建一个全局getSVG方法,该方法将一组图表作为
*论据
*/
Highcharts.getSVG=函数(图表){
var svgArr=[],
top=0,
宽度=0;
每个(图表,函数)(图表,i){
var svg=chart.getSVG(),
//获取要导出的SVG的宽度/高度
svgWidth=+svg.match(
/^]*宽度\s*=\s*\“?(\d+\”?[^>]*>/
)[1],
svgHeight=+svg.match(
/^]*高度\s*=\s*\“?(\d+)\”?[^>]*>/
)[1];
svg=svg.replace(
“请展示你在这方面的努力(你所做的代码)嗨,皮尤斯,我的代码将图形转换为pdf格式,但它不会将图像与图形一起转换为pdf格式。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<style type="text/css">
.container {
max-width: 600px;
min-width: 320px;
margin: 0 auto;
}
#buttonrow {
max-width: 600px;
min-width: 320px;
margin: 0 auto;
}
</style>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
/**
* Create a global getSVG method that takes an array of charts as an
* argument
*/
Highcharts.getSVG = function (charts) {
var svgArr = [],
top = 0,
width = 0;
Highcharts.each(charts, function (chart, i) {
var svg = chart.getSVG(),
// Get width/height of SVG for export
svgWidth = +svg.match(
/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/
)[1],
svgHeight = +svg.match(
/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/
)[1];
svg = svg.replace(
'<svg',
'<g transform="translate(' + i * svgWidth + ',' + 0 + ')" '
);
svg = svg.replace('</svg>', '</g>');
top += svgHeight;
width = Math.max(width, 2 * svgWidth);
svgArr.push(svg);
});
return '<svg height="' + (top / 2) + '" width="' + width +
'" version="1.1" xmlns="http://www.w3.org/2000/svg">' +
svgArr.join('') + '</svg>';
};
/**
* Create a global exportCharts method that takes an array of charts as an
* argument, and exporting options as the second argument
*/
Highcharts.exportCharts = function (charts, options) {
// Merge the options
options = Highcharts.merge(Highcharts.getOptions().exporting, options);
// Post to export server
Highcharts.post(options.url, {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: Highcharts.getSVG(charts)
});
};
var chart1 = Highcharts.chart('container1', {
chart: {
height: 200,
width: 400
},
title: {
text: 'First Chart'
},
credits: {
enabled: false
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
showInLegend: false
}],
exporting: {
enabled: false // hide button
}
});
var chart2 = Highcharts.chart('container2', {
chart: {
type: 'column',
height: 200,
width: 400
},
title: {
text: 'Second Chart'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [176.0, 135.6, 148.5, 216.4, 194.1, 95.6,
54.4, 29.9, 71.5, 106.4, 129.2, 144.0],
colorByPoint: true,
showInLegend: false
}],
exporting: {
enabled: false // hide button
}
});
$('#export-png').click(function () {
Highcharts.exportCharts([chart1, chart2]);
});
$('#export-pdf').click(function () {
Highcharts.exportCharts([chart1, chart2], {
type: 'application/pdf'
});
});
</script>
<div id="container1" class="container"></div>
<div id="container2" class="container"></div>
<div id="buttonrow">
<button id="export-png">Export to PNG</button>
<button id="export-pdf">Export to PDF</button>
</div>
</body>
</html>