复选框列表到itextsharp列表到pdf字段 [英] checkbox list to itextsharp list to pdf Field
问题描述
大家好
基本上,我有一个复选框列表,然后单击按钮,我要求itextsharp创建一个列表,然后根据检查的内容将其放在字段中.
这是我所拥有的:
Hi All
Basically, I have a checkbox list, and on button click, im asking itextsharp to create a list and put it in the field based on whats checked.
here''s what a i have:
using li = System.Web.UI.WebControls.ListItem;
using it = iTextSharp.text;
it.List intList = new it.List(it.List.UNORDERED);
foreach (li li in cblInterior.Items)
{
if (li.Selected == true)
{
intList.Add(li.Text);
}
}
pdfFormFields.SetField("InteriorText", intList);
但是,我在最后一行收到错误消息:"The best overloaded method match for ''iTextsharp.text.pdf.AcroFields.SetField(string, string)'' has some invalid arguments."
但是我无法说出我错过了什么. "intList.Add(li.Text)"是否已将其转换为字符串?
but, i get an error at the last line saying: "The best overloaded method match for ''iTextsharp.text.pdf.AcroFields.SetField(string, string)'' has some invalid arguments."
But I can''t tell what im missing. Doesnt "intList.Add(li.Text)" turn it into a string already? Is it a syntax problem with itextsharp?
推荐答案
这是VB.net示例: ^ ]
根据它以及您得到的异常,您不能仅将字符串键-值对传递给列表.如果要格式化列表,则应尝试将intList转换为格式化字符串.但是我不确定字段是否支持格式文本.
另请参阅: http://www.mikesdotnetting.com/Article/83/Lists-with-iTextSharp [ ^ ]
Here is a VB.net sample: Programmatically Complete PDF Form Fields using Visual Basic and the iTextSharp DLL[^]
According to it and the exception you got, you can not pass a list only string key-value pairs. If you want a formatted list you should try to convert intList to a formatted string. But I am not sure if fields support formatted text.
See also: http://www.mikesdotnetting.com/Article/83/Lists-with-iTextSharp[^]
这篇关于复选框列表到itextsharp列表到pdf字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!