예제 #1
0
 public static List<String> getProfileList() {
   List<String> ret = new ArrayList<>();
   for (PDFAFlavour pdfaFlavour : PDFAFlavour.values()) {
     ret.add(pdfaFlavour.getId());
   }
   return ret;
 }
예제 #2
0
  public static Pair<StringContentPayload, Boolean> runVeraPDF(
      Path input, String profile, boolean hasFeatures)
      throws VeraPDFException, IOException, JAXBException {

    PdfBoxFoundryProvider.initialise();
    PDFAFlavour flavour = PDFAFlavour.byFlavourId(profile);

    ValidatorConfig validatorConfig = ValidatorFactory.createConfig(flavour, true, 10);
    FeatureExtractorConfig featureConfig = FeatureFactory.defaultConfig();
    MetadataFixerConfig fixerConfig = FixerFactory.defaultConfig();
    EnumSet<TaskType> tasks = EnumSet.of(TaskType.VALIDATE);

    if (hasFeatures) {
      tasks.add(TaskType.EXTRACT_FEATURES);
    }

    ItemProcessor processor =
        ProcessorFactory.createProcessor(
            ProcessorFactory.fromValues(validatorConfig, featureConfig, fixerConfig, tasks));

    ProcessorResult result = processor.process(input.toFile());
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    boolean prettyPrint = true;
    ProcessorFactory.resultToXml(result, os, prettyPrint);

    IOUtils.closeQuietly(os);
    StringContentPayload s = new StringContentPayload(os.toString(RodaConstants.DEFAULT_ENCODING));
    return Pair.create(s, result.getValidationResult().isCompliant());
  }