Hi, I have this problem with fpdf. at the moment of generating the file, it launches this:
Instead of the simple hello world that I ask,
Here my controller function, the function is actionGenerate:
<?php
namespace backend\controllers;
use Yii;
use app\models\Reportes;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use rudissaar\fpdf\FPDF;
use yii\web\NotFoundHttpException;
use app\models\RegistroAdq;
use app\models\Adq;
use yii\filters\VerbFilter;
/**
* ReportesController implements the CRUD actions for Reportes model.
*/
class ReportesController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Reportes models.
* @return mixed
*/
public function actionIndex()
{
$dataProvider = new ActiveDataProvider([
'query' => Reportes::find(),
]);
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}
protected function findModel($id)
{
if (($model = Reportes::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
public function actionGenerar()
{
//$fecha_ini=$_POST['fecha_inicio'];
//$fecha_fin=$_POST['fecha_fin'];
//
//$radq=RegistroAdq::find()
//->where(['between', 'radq_fecha', $fecha_ini, $fecha_fin])
//->all();
//
//foreach ($radq as $dato) {
//$id=$dato->radq_adq;
//}
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 15);
$pdf->Cell(40, 10, 'Hello World');
$pdf->Output('I');
}
}
As you can see, it's a simple hello world, just to make it work and then make my complete pdf. I have already elaborated several but this is the first one I do in yii2, I hope you can help me.