Skip to content

Upgrading from 0.1.0 to 0.3.1 #152

@mrossard

Description

@mrossard

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(); 

Activity

Jean-Beru

Jean-Beru commented on Apr 9, 2025

@Jean-Beru
Contributor

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 the FileProcessor. Alternatively, to acquire a resource, you should employ the TempfileProcessor.

What objective are you aiming to accomplish with the string you retrieved?

mrossard

mrossard commented on Apr 9, 2025

@mrossard
Author

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

mrossard commented on Apr 9, 2025

@mrossard
Author

That being said, TempfileProcessor doesn't exist in 0.3.1, neither via composer nor via the zip package?

Jean-Beru

Jean-Beru commented on Apr 9, 2025

@Jean-Beru
Contributor

That being said, TempfileProcessor doesn't exist in 0.3.1, neither via composer nor via the zip package?

Indeed! Spoiler alert: a new version is coming with this processor.

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.

Is the serialization needed? You could directly return the StreamedResponse from $builder->process()->stream() and enjoy the benefits of PDF streaming.

mrossard

mrossard commented on Apr 9, 2025

@mrossard
Author

That being said, TempfileProcessor doesn't exist in 0.3.1, neither via composer nor via the zip package?

Indeed! Spoiler alert: a new version is coming with this processor.

in the meantime i copy/pasted it in my project and it works fine, thanks!

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.

Is the serialization needed? You could directly return the StreamedResponse from $builder->process()->stream() and enjoy the benefits of PDF streaming.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting feedbackWaiting for feedback from issuer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Jean-Beru@Neirda24@mrossard

        Issue actions

          Upgrading from 0.1.0 to 0.3.1 · Issue #152 · sensiolabs/GotenbergBundle