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


Java PDField.getValue方法代码示例

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


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

示例1: dumpFieldsInFile

import org.apache.pdfbox.pdmodel.interactive.form.PDField; //导入方法依赖的package包/类
private void dumpFieldsInFile(String file)
        throws IOException, CryptographyException {
    if (separator == null) throw new IllegalArgumentException("Separator cannot be null.");

    try (PDDocument document = PDDocument.load(file)) {
        if (document.isEncrypted()) {
            document.decrypt("");
            document.setAllSecurityToBeRemoved(true);
        }

        final PDDocumentCatalog documentCatalog = document.getDocumentCatalog();
        final PDAcroForm acrobatForm = documentCatalog.getAcroForm();

        if (acrobatForm == null) return;

        List<String> values = new ArrayList<>();

        for (String field : fields) {
            final PDField acrobatFormField = acrobatForm.getField(field);

            String value;

            if (acrobatFormField == null) {
                System.err.printf("Cannot find %s.%n", field);
                value = null;
            } else {
                value = acrobatFormField.getValue();
            }

            values.add((value == null ? "" : StringEscapeUtils.escapeCsv(value)));
        }

        System.out.println(StringUtils.join(values, separator));
    }
}
 
开发者ID:emcrisostomo,项目名称:pdfform,代码行数:36,代码来源:DumpCommand.java

示例2: addFieldString

import org.apache.pdfbox.pdmodel.interactive.form.PDField; //导入方法依赖的package包/类
private void addFieldString(PDField field, XHTMLContentHandler handler)
throws SAXException {
  // Pick partial name to present in content and altName for attribute
  // Ignoring FullyQualifiedName for now
  String partName = field.getPartialName();
  String altName = field.getAlternateFieldName();

  StringBuilder sb = new StringBuilder();
  AttributesImpl attrs = new AttributesImpl();

  if (partName != null) {
    sb.append(partName).append(": ");
  }
  if (altName != null) {
    attrs.addAttribute("", "altName", "altName", "CDATA", altName);
  }
  // return early if PDSignature field
  if (field instanceof PDSignatureField) {
    handleSignature(attrs, (PDSignatureField) field, handler);
    return;
  }
  try {
    // getValue can throw an IOException if there is no value
    String value = field.getValue();
    if (value != null && !value.equals("null")) {
      sb.append(value);
    }
  } catch (Exception e) {
    // swallow
  }

  if (attrs.getLength() > 0 || sb.length() > 0) {
    handler.startElement("li", attrs);
    handler.characters(sb.toString());
    handler.endElement("li");
  }
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:38,代码来源:PDF2XHTML.java


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