mejoras
This commit is contained in:
28
app/Http/Services/PdfProcessor.php
Normal file
28
app/Http/Services/PdfProcessor.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Spatie\PdfToText\Pdf;
|
||||
use PDFLib;
|
||||
|
||||
class PdfProcessor
|
||||
{
|
||||
public function extractAnnotations($path)
|
||||
{
|
||||
$text = (new Pdf())->setPdf($path)->text();
|
||||
// Analizar texto para detectar anotaciones
|
||||
return $this->parseAnnotations($text);
|
||||
}
|
||||
|
||||
public function embedAnnotations($originalPdf, $annotations)
|
||||
{
|
||||
$pdf = new PDFLib();
|
||||
$pdf->begin_document('', '');
|
||||
|
||||
foreach($annotations as $annotation) {
|
||||
$this->addAnnotationToPdf($pdf, $annotation);
|
||||
}
|
||||
|
||||
return $pdf->get_buffer();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user