/** * generates the command line need to execute the C42PDF tool in a shell. This requires that the * <code>Registry.getConvertToolPath()</code> and <code>Registry.getConvertToolName()</code> are * valid. * * @param documentName the name of the document you wish to create * @return */ private String createC42PDFCommandLine(String documentName) { return (Registry.getConvertToolPath() + File.separator + Registry.getConvertToolName() + (" -o " + _workingDir + File.separator + documentName + " -l " + _workingDir + File.separator + _fileList)); }
protected void createPDFFile() throws CreatePDFFileException { String cmdLine = null; try { File newPdfFile = new File(_workingDir + File.separator + _localFilename + EXTENTION); if (Registry.isCommandLineMode()) { handleMultipleDocuments(newPdfFile); } cmdLine = createC42PDFCommandLine(newPdfFile.getName()); if (log.isDebugEnabled()) { log.debug("Running " + cmdLine); } // run C42PDF to create the file & wait till it finishes. Process p = Runtime.getRuntime().exec(cmdLine); p.waitFor(); // check to see if it worked if (!newPdfFile.exists()) { log.warn("PDF File was not created!"); throw new CreatePDFFileException("PDF File was not created!"); } } catch (IOException e) { e.printStackTrace(); throw new CreatePDFFileException(e.toString()); } catch (InterruptedException e) { e.printStackTrace(); throw new CreatePDFFileException(e.toString()); } return; }
protected void getPages() throws FTPServerTimeoutException, FTPServerException, NoFTPServiceException { // Setup the ftp server FtpServer ftp; try { ftp = (FtpServer) Class.forName(Registry.getFTPService()).newInstance(); ftp.setServer(Registry.getUrl()); ftp.setPassword(Registry.getFtpPassword()); ftp.setUserName(Registry.getFtpUserName()); ftp.setPassive(Registry.usePassive()); ftp.setTimeout(Registry.getFtpTimeout()); // get the pages and store them in the _workingDir _pages = ftp.getFiles(getWssrdDocumentName(), _workingDir); if ((_pages.length == 1) && _pages[0].endsWith(".PDF")) { _fileType = PDF_FILETYPE; } } catch (InstantiationException e) { log.warn(e.getMessage()); throw new NoFTPServiceException(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }