Can we set max line length, using iText library?
Hello all,
I am using iText java libraries to convert .txt files to PDF. The following is my code: My text file has lines which are longer, and when I convert to PDF, the lines get wrapped. Is there a way that I can set max line length? Please advise...
Code:
public static void main(String[] args) {
try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("C:\\input.pdf"));
document.open();
String input = "C:\\input.txt";
BufferedReader in = new BufferedReader(new FileReader(input));
String str;
boolean hasPage = false;
while ((str = in.readLine()) != null) {
document.add(new Paragraph(str));
hasPage = true;
}
if (hasPage) {
document.close();
}
in.close();
}catch (Exception e) {
e.printStackTrace();
}