2021-11-27 11:15:23 -03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2021-11-27 12:51:28 -03:00
|
|
|
use Illuminate\Support\Facades\File;
|
2021-11-27 11:15:23 -03:00
|
|
|
|
|
|
|
class Librilladora extends Model {
|
|
|
|
use HasFactory;
|
|
|
|
|
2021-11-27 13:25:15 -03:00
|
|
|
|
2021-11-27 12:51:28 -03:00
|
|
|
public function prueba(string $fileName) {
|
2021-11-27 11:15:23 -03:00
|
|
|
$mpdf = new \Mpdf\Mpdf();
|
|
|
|
|
2021-11-27 12:51:28 -03:00
|
|
|
// // Write some HTML code:
|
|
|
|
// $mpdf->WriteHTML($nombre);
|
|
|
|
//
|
|
|
|
// // Output a PDF file directly to the browser
|
|
|
|
// $mpdf->Output();
|
|
|
|
//
|
|
|
|
// // Require composer autoload
|
|
|
|
// require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
$file = 'uploads/'.$fileName;
|
2021-11-27 13:25:15 -03:00
|
|
|
$mpdf->SetSourceFile($file);
|
2021-11-27 12:51:28 -03:00
|
|
|
$tplId = $mpdf->importPage(1);
|
|
|
|
$mpdf->useTemplate($tplId);
|
|
|
|
File::delete($file);
|
2021-11-27 11:15:23 -03:00
|
|
|
|
|
|
|
$mpdf->Output();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|