30 lines
693 B
PHP
30 lines
693 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class Librilladora extends Model {
|
|
use HasFactory;
|
|
|
|
|
|
public function prueba($fileName, $size) {
|
|
$file = 'uploads/'.$fileName;
|
|
|
|
$mpdf = new \Mpdf\Mpdf();
|
|
$pagecount = $mpdf->SetSourceFile($file);
|
|
$fin = ($size < $pagecount) ? $size : $pagecount;
|
|
for ($i = 1; $i <= $fin; $i++) {
|
|
$tplId = $mpdf->importPage($i);
|
|
$mpdf->useTemplate($tplId);
|
|
if ($i != $fin) $mpdf->AddPage();
|
|
}
|
|
|
|
$mpdf->Output();
|
|
File::delete($file);
|
|
}
|
|
}
|
|
|