Search code examples
phpmysqlarrayspdftkfdf

PDFtk fill multiple values in single PDF form text field


I am little confused how to fill muiltiple values in single textbox using pdftk.

What i have tried so far :

$dataFields = `pdftk $pdf_path dump_data_fields`;

I am able to get the data fields with this commnad.

Sample OUtPUT Of this :

---
FieldType: Text
FieldName: <<ProjectName>>
FieldNameAlt: <<ProjectName>>
FieldFlags: 0
FieldJustification: Left
---
FieldType: Text
FieldName: *<<ProjectAddress>><<ProjectCityState>>*
FieldNameAlt: <<ProjectAddress>><<ProjectCityState>>
FieldFlags: 0
FieldJustification: Left

But there are two values which i want to replace <<ProjectAddress>><<ProjectCityState>> with some other values for ex:, 21 jump street NY.I can replace single value but how to replace multiple value dynamically from array.


Solution

  • Okay.so i found a solution for my question. what i have done :

    1)save the field data in to one .txt file
    2)using command `$dataFields = `pdftk $pdf_path dump_data_fields output output.txt``;
    3)after that i have converted the file data in to array. using `$data = file('output.txt');` command and explode with new line.
    4)then i put condition that if the string contains`FileName:` keyword and make new array.
    5)and then compate it with my array and check.