libmergepdf icon indicating copy to clipboard operation
libmergepdf copied to clipboard

TcpdiDriver with PDF field

Open alexis-riot opened this issue 2 years ago • 7 comments

Hello,

I have a fillable PDF, when I save it with some fields filled, TCPDI Driver can't display they fields. You can simply reproduce this with the following PDF: example.pdf

firstname and lastname is filled (Toto / Rico). But if you pass it through TCPDI Driver (or FPDI), these data is not displayed.

Do you know how can I use TCPDI Driver with fillable PDF?

Thanks you.

alexis-riot avatar Dec 08 '21 14:12 alexis-riot

https://www.setasign.com/products/setapdf-merger/demos/assistant-demo/#p-300 This example should work for merging 2 PDF and conserve fields states.

In the code, we can see:


// merge all files
$document = $merger->merge();

// if form fields were merged, set a flag that introduce the
// reader application to re-render the form field appearances.
$acroForm = $document->getCatalog()->getAcroForm();
$fields = $acroForm->getFieldsArray();
if ($fields !== false && count($fields) > 0) {
    $acroForm->setNeedAppearances();
}

alexis-riot avatar Dec 08 '21 14:12 alexis-riot

please create a MR and possibly a testcase, i will take a look into it then

kaystrobach avatar Dec 08 '21 15:12 kaystrobach

please create a MR and possibly a testcase, i will take a look into it then

MR with what content ? I have no solution on your library for fix this problem about form fields.

alexis-riot avatar Dec 08 '21 15:12 alexis-riot

isn't that these 4 loc?

$acroForm = $document->getCatalog()->getAcroForm();
$fields = $acroForm->getFieldsArray();
if ($fields !== false && count($fields) > 0) {
    $acroForm->setNeedAppearances();
}

Seemed to me, that it's enough to put it in the end of the merge function - ?

kaystrobach avatar Dec 08 '21 15:12 kaystrobach

isn't that these 4 loc?

$acroForm = $document->getCatalog()->getAcroForm();
$fields = $acroForm->getFieldsArray();
if ($fields !== false && count($fields) > 0) {
    $acroForm->setNeedAppearances();
}

Seemed to me, that it's enough to put it in the end of the merge function - ?

I have take this code from SetaPDF-Merger. And your library is using TCPDI/FPDI Driver.

alexis-riot avatar Dec 08 '21 15:12 alexis-riot

isn't that these 4 loc?

$acroForm = $document->getCatalog()->getAcroForm();
$fields = $acroForm->getFieldsArray();
if ($fields !== false && count($fields) > 0) {
    $acroForm->setNeedAppearances();
}

Seemed to me, that it's enough to put it in the end of the merge function - ?

Because in your example, how you get $document ? On the example of SetaPDF, the document is returned by the merge() method. But in the case of your library, the merge method return the raw PDF merged and not the document.

alexis-riot avatar Dec 08 '21 16:12 alexis-riot

@kaystrobach Hello, any news?

alexis-riot avatar Dec 12 '21 20:12 alexis-riot