Ejemplo n.º 1
0
  /** Generates PDF using JOD Library (external library) */
  public ConverterProcessResult doJodConvert(
      File fileFullPath, File destinationFolder, String outputfile) {
    try {

      String jodPath = configurationDao.getConfValue("jod.path", String.class, "./jod");
      String officePath = configurationDao.getConfValue("office.path", String.class, "");

      File jodFolder = new File(jodPath);
      if (!jodFolder.exists() || !jodFolder.isDirectory()) {
        throw new Exception("Path to JOD Library folder does not exist");
      }

      ArrayList<String> argv = new ArrayList<String>();
      argv.add("java");

      if (officePath.trim().length() > 0) {
        argv.add("-Doffice.home=" + officePath);
      }
      String jodConverterJar = "";

      for (String jar :
          jodFolder.list(
              new FilenameFilter() {
                public boolean accept(File file1, String name) {
                  return name.endsWith(".jar");
                }
              })) {
        argv.add("-cp");
        if (jar.startsWith("jodconverter")) {
          jodConverterJar = jar;
        }
        argv.add(new File(jodFolder, jar).getCanonicalPath());
      }
      if (jodConverterJar.length() == 0) {
        throw new Exception("Could not find jodConverter JAR file in JOD folder");
      }

      argv.add("-jar");
      argv.add(new File(jodFolder, jodConverterJar).getCanonicalPath());
      argv.add(fileFullPath.getCanonicalPath());
      argv.add(new File(destinationFolder, outputfile + ".pdf").getCanonicalPath());

      return ProcessHelper.executeScript("doJodConvert", argv.toArray(new String[argv.size()]));

    } catch (Exception ex) {
      log.error("doJodConvert", ex);
      return new ConverterProcessResult("doJodConvert", ex.getMessage(), ex);
    }
  }
Ejemplo n.º 2
0
 private Long getDefaultLanguage() {
   return configurationDao.getConfValue(CONFIG_DEFAUT_LANG_KEY, Long.class, "1");
 }