我正在使用iTextSharp来填充由第三方创建和保护的PDF字段(我们无法对其进行修改)。
我在阅读之前预先填充了表单,以帮助跟踪我需要设置的值。这对大多数领域都有效。
我对PDF的内部工作原理并不太熟悉,但我已经取得了进展,因为我可以将所有字段设置为一个。有关领域是英国国民保险号码('NINO')。它由两个字母组成,然后是三个数字对和最后一个字母。例如JS 11 11 11 X
该字段的jsonised XML Xfa.DatasetsSom.Name2Node节点如下所示:
"Q18": {
"CompositeQuestion": {
"NINO": {
"QuestionArea": {
"HelpButton": {
"@xfa:dataNode": "dataGroup"
}
},
"NINO": {
"@xfa:dataNode": "dataGroup"
}
}
}
}
而不是在节点中具有实际值,它似乎指向'dataNode''dataGroup'。不确定这是什么。稍微浏览一下对象图后,我遇到了似乎描述这个模板的Xfa.TemplateSom.Name2Node。这是描述前两个字母:
"form1[0].AuthorisedOfficial[0].AuthOfficial[0].PanelBody[0].Column2[0].Q18[0].CompositeQuestion[0].NINO[0].NINO[0].Letters[0]": {
"field": {
"@name": "Letters",
"@w": "10mm",
"@h": "6mm",
"@locale": "en_GB",
"ui": {
"textEdit": {
"@hScrollPolicy": "off",
"border": {
"@hand": "right",
"fill": null,
"edge": {
"color": {
"@value": "128,195,184"
}
},
"corner": {
"@thickness": "0.176mm",
"color": {
"@value": "128,195,184"
}
}
},
"comb": {
"@numberOfCells": "2"
}
}
},
"font": {
"@typeface": "Arial"
},
"margin": {
"@topInset": "0mm",
"@bottomInset": "0mm",
"@leftInset": "0mm",
"@rightInset": "0mm"
},
"para": {
"@vAlign": "middle",
"@marginLeft": "0pt",
"@marginRight": "0pt",
"@spaceBelow": "0pt"
},
"assist": {
"speak": "National Insurance number first two letters"
},
"border": {
"edge": {
"@thickness": "0.1764mm",
"@presence": "hidden",
"color": {
"@value": "128,195,184"
}
},
"corner": {
"@thickness": "0.176mm",
"@presence": "hidden",
"color": {
"@value": "128,195,184"
}
}
},
"traversal": {
"traverse": {
"@ref": "Numbers1[0]"
}
},
"bind": {
"@match": "none"
},
"validate": {
"message": {
"text": {
"@name": "scriptTest"
}
}
},
"format": {
"picture": "text{AA}"
},
"event": [
{
"@activity": "change",
"@name": "event__change",
"script": {
"@contentType": "application/x-javascript",
"#text": "\tif (xfa.event.newText.length==2)\n\t\txfa.host.setFocus(Numbers1.somExpression);\n"
}
},
{
"@activity": "exit",
"@name": "event__exit",
"script": {
"@contentType": "application/x-javascript",
"#text": "\tif (this.rawValue != undefined) this.rawValue = this.rawValue.toUpperCase();\t\n\n"
}
}
]
}
},
但同样,没有字段包含设置值的值或明显的位置。它似乎也指另一个名为Numbers1 [0]的模板。
我在这里画一个空白。我的问题是,如果可能的话,任何人都会遇到类似的问题以及如何在模板中设置值以及在iTextSharp pdfStamper中保存实际值的位置。
手指交叉,谢谢。