Update Signature App.vue to use a converted pdf

Introduced a new helper ts function to download documents as PDFs and integrated with the existing workflow. Enhanced `PDFSignatureZoneAvailable` to implement `LocaleAwareInterface` for better locale management and added PDF conversion handling for non-PDF documents. Updated App.vue to use the new PDF download method.
This commit is contained in:
2024-11-15 14:17:26 +01:00
parent a312b45777
commit 03fe9a6d86
4 changed files with 55 additions and 8 deletions

View File

@@ -17,15 +17,30 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Chill\WopiBundle\Service\WopiConverter;
use Symfony\Contracts\Translation\LocaleAwareInterface;
class PDFSignatureZoneAvailable
class PDFSignatureZoneAvailable implements LocaleAwareInterface
{
private string $locale;
public function __construct(
private readonly EntityWorkflowManager $entityWorkflowManager,
private readonly PDFSignatureZoneParser $pdfSignatureZoneParser,
private readonly StoredObjectManagerInterface $storedObjectManager,
private readonly WopiConverter $converter,
) {}
public function setLocale(string $locale)
{
$this->locale = $locale;
}
public function getLocale()
{
return $this->locale;
}
/**
* @return list<PDFSignatureZone>
*/
@@ -38,10 +53,16 @@ class PDFSignatureZoneAvailable
}
if ('application/pdf' !== $storedObject->getType()) {
throw new \RuntimeException('Only PDF documents are supported');
$content = $this->converter->convert($this->getLocale(), $this->storedObjectManager->read($storedObject), $storedObject->getType());
} else {
$content = $this->storedObjectManager->read($storedObject);
}
$zones = $this->pdfSignatureZoneParser->findSignatureZones($this->storedObjectManager->read($storedObject));
$zones = $this->pdfSignatureZoneParser->findSignatureZones($content);
// free some memory as soon as possible...
unset($content);
$signatureZonesIndexes = array_map(
fn (EntityWorkflowStepSignature $step) => $step->getZoneSignatureIndex(),
$this->collectSignaturesInUse($entityWorkflow)