-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
waiting feedbackWaiting for feedback from issuerWaiting for feedback from issuer
Description
Hi,
I've been using this bundle since its early days on a small project, and i'm having some trouble upgrading it : i seem to get empty contents even though the generation seems to be just fine.
From what i could gather using my debugger, my call to $htmlPdfBuilder->generate()->process()
(i need the pdf as a string) ends up calling Sensiolabs\GotenbergBundle\Processor\NullProcessor
with chunks that look fine, but it obviously does nothing with them.
Any clue as to what I could be doing wrong?
The code is extremely simple and does seem to get me a correct response before i try to get its contents :
$builder = $this->pdf->html();
if (null !== $headerTemplate) {
$builder->header($headerTemplate, ['data' => $data]);
}
if (null !== $footerTemplate) {
$builder->footer($footerTemplate, ['data' => $data]);
}
return $builder->content($template, ['data' => $data])->generate()->process();
//In 0.1.0 was return $builder->content($template, ['data' => $data])->generate()->getContent();
Metadata
Metadata
Assignees
Labels
waiting feedbackWaiting for feedback from issuerWaiting for feedback from issuer
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Jean-Beru commentedon Apr 9, 2025
Hello @mrossard,
The builder is set to use the
NullProcessor
by default, meaning no action will be taken.If you wish to obtain a
SplFileInfo
, you should utilize theFileProcessor
. Alternatively, to acquire a resource, you should employ theTempfileProcessor
.What objective are you aiming to accomplish with the string you retrieved?
mrossard commentedon Apr 9, 2025
I had just found https://github.com/sensiolabs/GotenbergBundle/blob/main/docs/processing.md , sorry.
I'm returning the file as a string in a PdfEncoder in a project using api platform, it needs to implement Symfony\Component\Serializer\Encoder\EncoderInterface:encode(), which returns a string.
mrossard commentedon Apr 9, 2025
That being said, TempfileProcessor doesn't exist in 0.3.1, neither via composer nor via the zip package?
Jean-Beru commentedon Apr 9, 2025
Indeed! Spoiler alert: a new version is coming with this processor.
Is the serialization needed? You could directly return the StreamedResponse from
$builder->process()->stream()
and enjoy the benefits of PDF streaming.mrossard commentedon Apr 9, 2025
in the meantime i copy/pasted it in my project and it works fine, thanks!
I'm not sure i can skip the normalization/serialization part of api platform for a specific accept header, but that could be nice. I'll ask @soyuka if i find some time, it'd be nice for big documents.