当前位置: 首页>>代码示例>>Java>>正文


Java AcroFields.setField方法代码示例

本文整理汇总了Java中com.itextpdf.text.pdf.AcroFields.setField方法的典型用法代码示例。如果您正苦于以下问题:Java AcroFields.setField方法的具体用法?Java AcroFields.setField怎么用?Java AcroFields.setField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.itextpdf.text.pdf.AcroFields的用法示例。


在下文中一共展示了AcroFields.setField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPd3100SetVrPr4ToNo

import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/42819618/itext-fill-checkbox-with-value">
 * itext fill checkbox with value
 * </a>
 * <br/>
 * <a href="https://www.poreskaupravars.org/Documents/Doc/PD3100.pdf">
 * PD3100.pdf
 * </a>
 * <p>
 * This test uses a valid name and so at least creates
 * a PDF displayed with a somehow selected field. 
 * </p>
 * @see #testPd3100SetVrPr4ToNoAppend()
 */
@Test
public void testPd3100SetVrPr4ToNo() throws IOException, DocumentException
{
    try (   InputStream resource = getClass().getResourceAsStream("PD3100.pdf");
            OutputStream result = new FileOutputStream(new File(RESULT_FOLDER, "PD3100-SetVrPr4ToNo.pdf"))  )
    {
        PdfReader pdfReader = new PdfReader(resource);
        PdfStamper pdfStamper = new PdfStamper(pdfReader, result, (char)0, false);
        AcroFields acroFields = pdfStamper.getAcroFields();
        System.out.println("Available values for VrPr4: " + Arrays.asList(acroFields.getAppearanceStates("VrPr4")));
        acroFields.setField("VrPr4", "No");
        pdfStamper.close();
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:29,代码来源:SetCheckBox.java

示例2: testFillInForm

import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
/**
     * <a href="http://stackoverflow.com/questions/28967737/itextsharp-setfield-for-fields-with-same-name-on-different-pages">
     * iTextSharp SetField for fields with same name on different pages
     * </a>
     * <p>
     * Reproducing the issue with iText
     * </p>
     */
    @Test
    public void testFillInForm() throws IOException, DocumentException
    {
        try (   InputStream resource = getClass().getResourceAsStream("ING_bewindvoering_regelen_tcm162-49609.pdf");
                OutputStream result = new FileOutputStream(new File(RESULT_FOLDER, "hybrid-form-fillin.pdf"))   )
        {
            PdfReader reader = new PdfReader(resource);
            PdfStamper stamper = new PdfStamper(reader, result);
            AcroFields fields = stamper.getAcroFields();
            fields.setField("topmostSubform[0].CheckBox2A[0]", "1");
//            fields.setField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1");
            stamper.close();
        }
    }
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:23,代码来源:DuplicateHybridFormNames.java

示例3: setField

import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
private static void setField(AcroFields fields, String key, String value) {
  try {
    fields.setField(key, value);
  } catch(DocumentException | IOException e) {
    throw new RuntimeException("Error setting PDF field", e);
  }
}
 
开发者ID:obiba,项目名称:mica2,代码行数:8,代码来源:PdfUtils.java

示例4: testPd3100SetVrPr4ToNoAppend

import com.itextpdf.text.pdf.AcroFields; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/42819618/itext-fill-checkbox-with-value">
 * itext fill checkbox with value
 * </a>
 * <br/>
 * <a href="https://www.poreskaupravars.org/Documents/Doc/PD3100.pdf">
 * PD3100.pdf
 * </a>
 * <p>
 * This test uses a valid name in append mode and so creates
 * a PDF displayed in Adobe Reader with a selected field as
 * desired. 
 * </p>
 * @see #testPd3100SetVrPr4ToNoAppend()
 */
@Test
public void testPd3100SetVrPr4ToNoAppend() throws IOException, DocumentException
{
    try (   InputStream resource = getClass().getResourceAsStream("PD3100.pdf");
            OutputStream result = new FileOutputStream(new File(RESULT_FOLDER, "PD3100-SetVrPr4ToNoAppend.pdf"))  )
    {
        PdfReader pdfReader = new PdfReader(resource);
        PdfStamper pdfStamper = new PdfStamper(pdfReader, result, (char)0, true);
        AcroFields acroFields = pdfStamper.getAcroFields();
        System.out.println("Available values for VrPr4: " + Arrays.asList(acroFields.getAppearanceStates("VrPr4")));
        acroFields.setField("VrPr4", "No");
        pdfStamper.close();
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:30,代码来源:SetCheckBox.java


注:本文中的com.itextpdf.text.pdf.AcroFields.setField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。