You see, I want my project, hosted on 000webhost, to be able to print PDF files. This is the function of my controller:
public function imprimir(Juego $j){
$pdf = PDF::loadView('pdf.juego', compact('j'));
$salida=$pdf->output();
$ruta='C:/Users/pcx/Desktop/Juego '.$j->numero.' '.$j->nombre.'.pdf';
file_put_contents($ruta, $salida);
return back()->with('message',['success','El PDF con los datos del juego se han creado con exito. Buscalo en tu escritorio.']);
}
For this, I have imported use Barryvdh\DomPDF\Facade as PDF;
And this is what I want to print:
@extends('layouts.app')
<html lang="es">
<body>
<font size="15" style="display: inline;">Juego Nº {{$j->numero}}: {{$j->nombre}}</font> <img style="width: 68px; height: 68px;" align="right" src="{{url($j->ruta())}}"/>
<hr>
<div class="row justify-content-center">
<div class="col-md-5 card card-1">
<div class="card-body">
<p><b>Materiales:</b> {{$j->materiales}}</p><br>
<p><b>Agrupación de los jugadores:</b> {{$j->agrupacion->nombre}}</p><br>
<h3>Organización:</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->organizacion}}</p>
<br><br><br>
<h3>Desarrollo del juego</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->desarrollo}}</p>
@if($j->observaciones!="*")
<br><br>
<h3>Reglas y observaciones:</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->observaciones}}</p>
@endif
@if($j->variantes!="*")
<br><br>
<h3>Variantes:</h3>
<p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->variantes}}</p>
@endif
<?php
$contenidos=$j->enlaces;
?>
@if(count($contenidos))
<br><br><br>
<h3>Contenidos:</h3>
@foreach($contenidos as $contenido)
<span class="badge badge-cat badge-info">{{$contenido->contenido->nombre}}</span>
@endforeach
@endif
</div>
</div>
</div>
</body>
</html>
The problem is that the following error message appears:
How do I manage to print the project?
I've also tried things like the $pdf->download()
function, but it also fails.