pessoal o que estou fazendo de errado?
estou baixando de um servidor FTP um arquivo PDF e jogando dentro do tomcat
dessa forma:
ftp.connect("servidor");
if(FTPReply.isPositiveCompletion(ftp.getReplyCode())){
ftp.login("user", "senha");
String PS = System.getProperty("file.separator");
larquivos = ftp.listNames("/teste");
if(larquivos != null){
/*session = new SessionBean();
session.setDocumentos(larquivos);*/
FacesContext fc = FacesContext.getCurrentInstance();
ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
String realpath = sc.getRealPath(File.separator+"temp");
fio = new FileOutputStream(realpath+PS+larquivos[0]);
ftp.retrieveFile(larquivos[0], fio);
ate aqui ele joga certo dentro da pasta temp do tomcat
apos isso faço a contagem de paginas que teme este pdf o que esta me retornando um erro
FacesContext fc = FacesContext.getCurrentInstance();
ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
String realpath = sc.getRealPath(File.separator+"temp");
String UH = System.getProperty("user.home");
String PS = System.getProperty("file.separator");
File pdf = new File(realpath+PS+arquivo);
FileInputStream fin = new FileInputStream(pdf);
pdfReader = new PdfReader(fin);
qtPaginas = pdfReader.getNumberOfPages();
erro gerado:
com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found.
cause: PDFException
sera que alguem poderia me ajudar com este problema…
obrigado!!
abç