I have an array of strings as follows: -
String[] data = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}.
Now I want to write these data lines to a pdf file under another, for example: -
1. Sunday
2. Monday
3. Tuesday
4. Wednesday
5. Thursday
6. Friday
7. Saturday.
I use itext to achieve this. Below is the code snippet that I am using
for(int i= 0; i< data.length;i++)
{
Document document=new Document();
PdfWriter.getInstance(document, new FileOutputStream(directory));
document.open();
document.add(new Paragraph(data[i]));
document.add(Chunk.NEWLINE);
document.close();
}
Problem: -
The pdf file I get has only: -
- saturday.
Please, help.
source
share