librilladora/app/Models/Librilladora.php

34 lines
772 B
PHP
Raw Normal View History

2021-11-27 11:15:23 -03:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\File;
2021-11-27 11:15:23 -03:00
class Librilladora extends Model {
use HasFactory;
public function prueba(string $fileName) {
2021-11-27 11:15:23 -03:00
$mpdf = new \Mpdf\Mpdf();
// // 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;
$mpdf->SetSourceFile($file);
$tplId = $mpdf->importPage(1);
$mpdf->useTemplate($tplId);
File::delete($file);
2021-11-27 11:15:23 -03:00
$mpdf->Output();
}
}