什么是检查使用iTextSharp的pdf文件的复选框领域常见的方式?

问题描述 投票:6回答:6

我填充数据使用iTextSharp的一个可填写的PDF。有在PDF表单中的复选框的n个。我已经为使用“是”或“否”的复选框的值。这工作得很好。但是,一些复选框不会以这种方式工作;相反,我需要使用1或0,使其工作。因此,谁能帮我什么是检查/使用iTextSharp的取消复选框在PDF中的常见方法是什么?

提前致谢,

白雪公主

c# pdf itextsharp
6个回答
11
投票

打开PDF选择和转换。

PdfReader reader = new PdfReader(fileNameIn);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(fileNameOut));
AcroFields form = stamper.getAcroFields();

检查表单对象的字段>键>查看结果找到一个复选框的字符串值,在我的情况下是“检查BOX1”

String[] checkboxstates = form.GetAppearanceStates("Check Box1");

检查checkboxstates变量。非[0] =值检查,[1] =的检查值。然后让它检查

fields.SetField("Check Box1", checkboxstates[1])

7
投票

你可以用这种方式找到:

PdfReader reader = new PdfReader(fileNameIn);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(fileNameOut));
AcroFields form = stamper.getAcroFields();

form.setField("Name","Test Name");
form.setField("odot","123456");
form.setField("Consortium","A Testing Co");
form.setField("PName","My Name");
form.setField("date","10/14/03");
form.setField("Box1","true"); //This is the checkbox control
stamper.close();

希望这有助于


3
投票

有没有“共同方式”。你需要知道,以改变他们的选中/清除值。

有一个类似的问题,我回答,我展示了如何找出这些价值观......啊!

Get the export value of a checkbox using iTextSharp


2
投票

pdfFormFields.SetField( “formfieldchkbox”, “是”); pdfFormFields.SetField( “formfieldchkbox”, “否”);

这应该做的工作。


0
投票

我发现我可以使用Adobe Acrobat设置复选框控制的出口值在PDF文件中,当出口值设置为“anytext”我可以检查使用下面的代码的复选框:

form.setField("Box1","anytext")

Property window of Check box


0
投票

我做了这样的

stamp.AcroFields.SetField("chk1", "Yes");
stamp.AcroFields.SetField("chk2", "No");
© www.soinside.com 2019 - 2024. All rights reserved.