how can I convert pdf file to word file using Java -


how can convert pdf file word file using java?

and, easy looks like?

try pdfbox

public class pdftextreader {    static string pdftotext(string filename) {         pdfparser parser;         string parsedtext = null;         pdftextstripper pdfstripper = null;         pddocument pddoc = null;         cosdocument cosdoc = null;         file file = new file(filename);         if (!file.isfile()) {             system.err.println("file " + filename + " not exist.");             return null;         }         try {             parser = new pdfparser(new fileinputstream(file));         } catch (ioexception e) {             system.err.println("unable open pdf parser. " + e.getmessage());             return null;         }         try {             parser.parse();             cosdoc = parser.getdocument();             pdfstripper = new pdftextstripper();             pddoc = new pddocument(cosdoc);             parsedtext = pdfstripper.gettext(pddoc);         } catch (exception e) {             system.err                     .println("an exception occured in parsing pdf document."                             + e.getmessage());         } {             try {                 if (cosdoc != null)                     cosdoc.close();                 if (pddoc != null)                     pddoc.close();             } catch (exception e) {                 e.printstacktrace();             }         }         return parsedtext;     }     public static void main(string args[]){           try {              string content = pdftotext(pdf_file_path);              file file = new file("/sample/filename.txt");              // if file doesnt exists, create             if (!file.exists()) {                 file.createnewfile();             }              filewriter fw = new filewriter(file.getabsolutefile());             bufferedwriter bw = new bufferedwriter(fw);             bw.write(content);             bw.close();              system.out.println("done");          } catch (ioexception e) {             e.printstacktrace();         }     }  } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -