2017-02-27 74 views
1

我很困惑如何使用pdftk在单个文本框中填充多个值。PDFtk在单个PDF表单文本字段中填充多个值

是我迄今为止尝试:

$dataFields = `pdftk $pdf_path dump_data_fields`; 

我能与此commnad得到的数据字段。

样本输出这一点:

--- 
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一些其他值。我可以取代单一的价值,但如何更换多个值动态从数组中。

回答

0

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.