在包含FPDF的PDF中包括JS生成的IMG

时间:2019-01-31 16:34:12

标签: javascript php google-visualization fpdf

我对此有一些问题。我试图将包含通过JS与Google Charts API生成的图像的PDF包含在PDF中。

问题是我不知道如何将图像源发送到php代码。

<?php
require('../FPDF/fpdf.php');

class PDF extends FPDF
{
	// Cabecera de página
	function Header()
	{
	    // Logo
	    $this->Image('../resources/wejudgegrande.png',10,8,63);
	    // Arial bold 15
	    $this->SetFont('Arial','B',15);
	    // Movernos a la derecha
	    $this->Cell(120);
	    // Título
	    $this->Cell(30,10,'INFORME DE TRABAJO',0,0,'C');
	    // Salto de línea
	    $this->Ln(8);

		$fecha1="01/01/2019";
		$fecha2="01/01/2019";
	    $lapso = $fecha1.' - '.$fecha2;
	    $this->Cell(120);
	    $this->SetFont('Arial','B',10);
	    $this->Cell(8,10,$lapso,0,0,'C');
	    $this->Ln(20);
	}

}



// Creación del objeto de la clase heredada
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);

		//DATOS PERSONALES
		$nombre="Pablo González de la Iglesia";
		$email="pablo.gonzalez97@icloud.com";
		$dni="71461083-Z";
		$ciudad="León";

		$nombre=utf8_decode($nombre);
		$email=utf8_decode($email);
		$dni=utf8_decode($dni);
		$ciudad=utf8_decode($ciudad);

		$pdf->Cell(10);
	    $pdf->SetFont('Arial','B',10);
	    $pdf->Cell(8,10,$nombre,0,0,'L');
	    $pdf->Ln(8);

	    $pdf->Cell(10);
	    $pdf->SetFont('Arial','B',10);
	    $pdf->Cell(8,10,$email,0,0,'L');
	    $pdf->Ln(8);

	    $pdf->Cell(10);
	    $pdf->SetFont('Arial','B',10);
	    $pdf->Cell(8,10,$dni,0,0,'L');
	    $pdf->Ln(8);

	    $pdf->Cell(10);
	    $pdf->SetFont('Arial','B',10);
	    $pdf->Cell(8,10,$ciudad,0,0,'L');
	    $pdf->Ln(8);

	    $pdf->Image( HERE I WANT TO INSERT THE IMAGE SOURCE);

	    //OTRAS COSAS
$pdf->Output();
?>

这是我在页面中内部图像源的方式。这只会打印图像的来源。

<html>
	<head>
		<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
	</head>
	
	<body>
		<div>
			<div id="mapa1"></div>
		</div>
	</body>
	<script>
		google.charts.load('current', {
		'packages':['geochart'],
		// Note: you will need to get a mapsApiKey for your project.
		// See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings
		'mapsApiKey': 'AIzaSyCBvatIme596a7vSTsiu6h9jakhY5gLnuY'
		});
		google.charts.setOnLoadCallback(drawRegionsMap);

		function drawRegionsMap() {
		    var data = google.visualization.arrayToDataTable([
			['Country', 'Nota media'],
			['ES-CL', 90],
			['ES-MD', 85],
			['ES-MC', 70],
			['ES-CT', 92],
			]);

			var options = {
			'title':'Map',
			'width': 480,
			'height': 480,
			region: 'ES',
			'resolution':'provinces',
			colorAxis: {minValue:60, maxValue:100, colors: ['white','#0080FF']},
			backgroundColor: 'white',
			datalessRegionColor: 'white',
			defaultColor: '#f5f5f5',


			};

			var chart_div = document.getElementById('mapa1');
			var chart = new google.visualization.GeoChart(chart_div);

			google.visualization.events.addListener(chart, 'ready', function () {
		        chart_div.innerHTML = chart.getImageURI();
		        console.log(chart.getImageURI());
		    });

			chart.draw(data, options);
			        
		}

</script>

如果有人可以帮助我,将不胜感激

0 个答案:

没有答案