本文整理汇总了Java中com.itextpdf.text.pdf.AcroFields.getAppearanceStates方法的典型用法代码示例。如果您正苦于以下问题:Java AcroFields.getAppearanceStates方法的具体用法?Java AcroFields.getAppearanceStates怎么用?Java AcroFields.getAppearanceStates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.pdf.AcroFields
的用法示例。
在下文中一共展示了AcroFields.getAppearanceStates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testShowPdfExampleStates
import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/39450688/itext-pdf-checkboxon-off-not-appearing-for-some-pdf">
* IText Pdf - Checkbox(On/Off) not appearing for some pdf
* </a>
* <br/>
* <a href="http://www.filedropper.com/pdfexample_1">
* PDF example.pdf
* </a>
* <p>
* The observations of the OP cannot be reproduced.
* </p>
*/
@Test
public void testShowPdfExampleStates() throws IOException
{
String resourceName = "PDF example.pdf";
try ( InputStream resource = getClass().getResourceAsStream(resourceName) )
{
PdfReader reader = new PdfReader(resource);
AcroFields form = reader.getAcroFields();
String[] values = form.getAppearanceStates("claimsType");
System.out.printf("\n%s\nThe appearance states of claimsType are %s.\n", resourceName, Arrays.asList(values));
}
}
示例2: testShowPdfTest2States
import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/39450688/itext-pdf-checkboxon-off-not-appearing-for-some-pdf">
* IText Pdf - Checkbox(On/Off) not appearing for some pdf
* </a>
* <br/>
* <a href="http://www.filedropper.com/pdftest2">
* PDF test 2.pdf
* </a>
* <p>
* The observations of the OP cannot be reproduced.
* </p>
*/
@Test
public void testShowPdfTest2States() throws IOException
{
String resourceName = "PDF test 2.pdf";
try ( InputStream resource = getClass().getResourceAsStream(resourceName) )
{
PdfReader reader = new PdfReader(resource);
AcroFields form = reader.getAcroFields();
String[] values = form.getAppearanceStates("claimsType");
System.out.printf("\n%s\nThe appearance states of claimsType are %s.\n", resourceName, Arrays.asList(values));
}
}
示例3: setField
import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
private static void setField(AcroFields fields, String key, Boolean value) {
String[] states = fields.getAppearanceStates(key);
if(states.length > 0) setField(fields, key, states.length > 1 ? states[value.booleanValue() ? 1 : 0] : states[0]);
}