add line break when filling data
neutralchung opened this issue · 6 comments
Hello, I would like to ask about how to add a line break when filling form? I tried '\n' and <'br'>. But it is not working. It is any way to insert a line break? Thanks.
Have you tried \r\n
? If that doesn't work I have no idea either.
I tried but still no use. Hope others can find the solution.
Have you tried if you can enter a linebreak when you use some PDF reader to fill the form? I think you can restrict input fields in PDF so that they don't allow linebreaks.
In any case I don't think this is an issue we can fix here, so I'm closing this.
The input fields can only multiline input. So there is no problem with the field. Only using code cannot insert linebreak.
Can you fill the form in a reader program and somehow save the form data as Xfdf file? That's the XML format that is used to store and load form data. It should look something like this: https://github.com/mikehaertl/php-pdftk/blob/master/tests/files/XfdfFileTest.xfdf
Then you could check what the reader writes to that file for a linebreak.
I just did a quick test myself:
- Create a XFDF file from Acrobat with linebreaks under windows. Result: The XFDF data contains DOS line endings (
\r\n
) - Used this file with
pdftk
to fill a form: works - Changed the line endings in the XFDF file manually to
\n
and filled the form again: works - Checked if I can create a XFDF file with linebreaks with php-pdftk: works
I've also added this to the tests:
php-pdftk/tests/XfdfFileTest.php
Line 30 in c856d2d
php-pdftk/tests/files/XfdfFileTest.xfdf
Lines 68 to 72 in c856d2d
So I can't find any issue. The only thing I had to make sure: You really need to enable the multiline option when you create the PDF.