java - Create a New Page During Text to PDF conversion Using Itext -
i converting text file pdf using itext. conversion works fine need during conversion if bufferedreader encounters text, new pdf page started. have tried new page not started when text encountered. sample code below(just relevant part).
document output = new document(pagesize.b3); fileinputstream fs = new fileinputstream("c:/abc statements final/file.txt"); fileoutputstream file = new fileoutputstream(new file("c:/pdf statements/file.pdf")); bufferedreader br = new bufferedreader(new inputstreamreader(fs)); pdfwriter writer = pdfwriter.getinstance(output, file); output.open(); writer.open(); ............................. string pageend = "page total"; string trimmedend = br.readline().trim(); if (trimmedend.startswith(pageend)) { output.newpage(); }
maybe need change if
-statement this:
string pageend = "page total"; ... if (trimmedend.tolowercase().contains(pageend)) { ... }
this way, avoid case-sensitivity , avoid problem of having characters aren't considered being white space before "page total". of course: educated guess. don't know original data stream looks like.