Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Melodia's avatar

How to get input values to the pdf file using Dompdf

Am using Dompdf to generate pdf files. Everything works but I cannot see a way to get dynamic data.

The view looks like this:

<a href="{{ url('/admin/pdf') }}">Download PDF</a>
<div class="form">
    <div class="flex" style="display: flex;">
        <div class="form-group" style="margin-bottom: 5px;">
            <label>Name</label>
            <input type="text" name="name">
        </div>

        <div class="form-group">
            <label>Email</label>
            <input type="email" name="email">
        </div>      
    </div>

    <div class="form-group">
        <label>Data</label>
        <input type="text" name="data">
    </div>
</div>

If I type the input values and click on download, I will only see the label values and not of the inputs and I assume it is because when I type, the value does not get updated.

How can I get the input values to the pdf file?

0 likes
1 reply
bobbybouwmann's avatar

Not really sure why you want to print the form in a pdf. Normally when generating a pdf you have a view and you pass some data to that view and insert it in there. Just like a normal view where you use blade variables.

So I expect you to have a controller that is returning a view. After submitting the form you will have another controller action that takes a view, prints the submitted values in the view and then compiles that down to a PDF.

What is your current flow right now? How do you want it to work?

Please or to participate in this conversation.