1. In some applications we may come across the situations where we need to create MS-Word files from the given data.
2. When you search in Google for JAVA APIs for creating MS-Word files the first solution you will get is POI API.
3. Apache provides this POI API to handle MS office files such as doc(x), xls(x) and ppt(x) files.
4. POI API is excellent to handle with Excel files but its API is not very comfortable to deal doc or docx files.
5. So another alternate to create word file is using iTEXT.
6. Using iTEXT we can create RTF files which can be opened using word.
7. A rich text file, or RTF file, is a file that is supported by Microsoft Word. This means that you can open any RTF file within Word.
8. Another advantage is there is no need to learn separate API for word. We can use the same API which can be used for creating PDF.
9. Only difference is we need to user RTFWriter instead of PDFWriter everything else will be similar to creating PDF
To create PDF using iTEXT
Document document = new Document ();
File fl = new File(path+ ".pdf");
FileOutputStream fos = new FileOutputStream(fl);
PdfWriter.getInstance(document, fos);
document.open();
To create RTF file using iTEXT
Document document = new Document();
File fl = new File(path+ ".rtf");
FileOutputStream fos = new FileOutputStream(fl);
RtfWriter writer=RtfWriter.getInstance(document, fos);
Hope this information helps you some where …..
Cheers,
Vijay Satlawar
good one,,,very nice
ReplyDeleteC# Converting PDF document to text, word...
ReplyDeletePlease let me which version of Itext jar will support for RtfWriter class
ReplyDelete2. i am trying with Itext 2.17.jar RtfWriter is not supporting