how to convert pdf file into doc file and display this doc file on jeditor pane. please any one help me thanks
Asked
Active
Viewed 1,375 times
2 Answers
1
I am assuming what you want to do is read a PDF, and display its contents as text in a JTextArea. Probably the easiest way to do this would be using Apache's PDFBox. The PDFTextStripper
class should help you accomplish this:
PDDocument doc = PDDocument.load(new File("/path/to/file.pdf"));
String text = new PDFTextStripper().getText(doc);
// display in some JTextArea
You can find several other examples in the tutorials. If formatting is important, you can also try converting it to an image, or use a library like JMagick.
-
thanks for reply but second line throw exception. like this Exception in thread "main" java.lang.NoClassDefFoundError: org/fontbox/afm/FontMetric – sandybarasker Jul 30 '12 at 11:00
-
After downloading [PDFBox](http://sourceforge.net/projects/pdfbox/files/), make sure you copy all the jars in the lib folder into your project folder. – Jeshurun Jul 30 '12 at 15:09
0
You can read PDF contect by using itext. Examples are there in below link
http://itextpdf.com/book/toc.php
But if the requirement is just to display PDF content than I believe you can use PDFRenderer to display PDF document.
http://www.javaworld.com/javaworld/jw-06-2008/jw-06-opensourcejava-pdf-renderer.html?page=1

Ankur Jain
- 16
- 1