<?php
function imprimeCadena ($cadena,$pdf)
{
	$n=90;

	if(strlen($cadena)>$n)
	{
		while(substr($cadena,$n,1)!=" ")
		{
			$n--;
		}
		$cadenaSobrante=substr($cadena,$n,strlen($cadena)-$n);
		$pdf->Cell(0,6,'   '.substr($cadena,0,$n),0,1);

		if(strlen($cadenaSobrante)>0)
		{
			$cadenaSobrante=substr($cadenaSobrante,1,strlen($cadenaSobrante));
			return imprimeCadena ($cadenaSobrante,$pdf);
		}
	} else
	{
		$pdf->Cell(0,6,'   '.substr($cadena,0,$n),0,1);
	}
}

$tipoinforme=$_REQUEST['tipoinforme'];

require("../../include/fpdf.php");

$pdf=new FPDF();
$pdf->AddPage();
$pdf->AddFont('MiArial','','arial.php');
$pdf->SetLeftMargin(15);
$pdf->SetRightMargin(15);
include ("cabecerainforme.php");

switch($tipoinforme)
{
	case 0:
		$ninforme="informediversificacion.pdf";
		include ("creainformediversificacion.php");
		break;
	case 1:
		$ninforme="informecualificacionprof.pdf";
		include ("creainformecualipro.php");
		break;
	case 2:
		$ninforme="informefinetapaprim.pdf";
		include ("creainformefinepcm.php");
		break;
	case 3:
		$ninforme="informefinetapaprim.pdf";
		include ("creainformefinepex.php");
		break;
}

$pdf->Ln(10);

$pdf->Output($ninforme,D);
?>
