Files
Nexora/app/Http/Services/PdfProcessor.php

28 lines
615 B
PHP
Raw Normal View History

2025-05-23 00:26:53 +02:00
<?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();
}
}