PDFtk 在单个 PDF 表单文本字段中填充多个值
PDFtk fill multiple values in single PDF form text field
我不太清楚如何使用 pdftk 在单个文本框中填充多个值。
到目前为止我已经尝试了什么:
$dataFields = `pdftk $pdf_path dump_data_fields`;
我可以使用此命令获取数据字段。
示例输出:
---
FieldType: Text
FieldName: <<ProjectName>>
FieldNameAlt: <<ProjectName>>
FieldFlags: 0
FieldJustification: Left
---
FieldType: Text
FieldName: *<<ProjectAddress>><<ProjectCityState>>*
FieldNameAlt: <<ProjectAddress>><<ProjectCityState>>
FieldFlags: 0
FieldJustification: Left
但是有两个值我想用一些其他值替换 <<ProjectAddress>><<ProjectCityState>>
例如:21 jump street NY
。我可以替换单个值,但如何从数组中动态替换多个值。
Okay.so 我找到了解决问题的方法。我做了什么:
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.
我不太清楚如何使用 pdftk 在单个文本框中填充多个值。
到目前为止我已经尝试了什么:
$dataFields = `pdftk $pdf_path dump_data_fields`;
我可以使用此命令获取数据字段。
示例输出:
---
FieldType: Text
FieldName: <<ProjectName>>
FieldNameAlt: <<ProjectName>>
FieldFlags: 0
FieldJustification: Left
---
FieldType: Text
FieldName: *<<ProjectAddress>><<ProjectCityState>>*
FieldNameAlt: <<ProjectAddress>><<ProjectCityState>>
FieldFlags: 0
FieldJustification: Left
但是有两个值我想用一些其他值替换 <<ProjectAddress>><<ProjectCityState>>
例如:21 jump street NY
。我可以替换单个值,但如何从数组中动态替换多个值。
Okay.so 我找到了解决问题的方法。我做了什么:
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.