【问题标题】:PDFtk fill multiple values in single PDF form text fieldPDFtk 在单个 PDF 表单文本字段中填充多个值
【发布时间】:2017-02-27 06:12:58
【问题描述】:

我有点困惑如何使用 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

但是有两个值我想用其他值替换 &lt;&lt;ProjectAddress&gt;&gt;&lt;&lt;ProjectCityState&gt;&gt;,例如:21 jump street NY。我可以替换单个值,但如何从数组中动态替换多个值。

【问题讨论】:

    标签: php mysql arrays pdftk fdf


    【解决方案1】:

    好的。所以我为我的问题找到了解决方案。我做了什么:

    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.
    

    【讨论】:

    • 您还可以添加| grep FieldName 以更快地一步过滤名称。
    猜你喜欢
    • 2021-01-01
    • 1970-01-01
    • 2013-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多