import java.io.File;
import java.io.FileOutputStream;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
import com.lowagie.text.Document; import com.lowagie.text.Paragraph;
import com.lowagie.text.rtf.RtfWriter2;
public class App {
public static void main(String[] args) {
try {
Document document = new Document();
File file = new File("Target/file.doc");
if(!file.exists())
file.createNewFile();
RtfWriter2.getInstance(document, new FileOutputStream("Target/file.doc"));
System.out.println("file created");
document.open();
PdfReader reader = new PdfReader("Source/recommendation.pdf");
int n = reader.getNumberOfPages();
System.out.println("total no of pages:::"+n);
String s="";
for(int i=1;i<=n;i++)
{
s=PdfTextExtractor.getTextFromPage(reader, i);
System.out.println("string:::"+s);
System.out.println("====================");
document.add(new Paragraph(s));
document.newPage();
}
document.close();
System.out.println("completed");
} catch (Exception de) {}
}
}
import java.io.FileOutputStream;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
import com.lowagie.text.Document; import com.lowagie.text.Paragraph;
import com.lowagie.text.rtf.RtfWriter2;
public class App {
public static void main(String[] args) {
try {
Document document = new Document();
File file = new File("Target/file.doc");
if(!file.exists())
file.createNewFile();
RtfWriter2.getInstance(document, new FileOutputStream("Target/file.doc"));
System.out.println("file created");
document.open();
PdfReader reader = new PdfReader("Source/recommendation.pdf");
int n = reader.getNumberOfPages();
System.out.println("total no of pages:::"+n);
String s="";
for(int i=1;i<=n;i++)
{
s=PdfTextExtractor.getTextFromPage(reader, i);
System.out.println("string:::"+s);
System.out.println("====================");
document.add(new Paragraph(s));
document.newPage();
}
document.close();
System.out.println("completed");
} catch (Exception de) {}
}
}
No comments:
Post a Comment