java - How to set the size of font while writing to pdf file -
i'm reading text .txt file , writing pdf file.but in pdf texts showing bigger fonts. though i've changed font size of .txt file bigger or small fonts in pdf same.
part of code working reading writing in text file
document document = new document(pagesize.a4.rotate(), 36, 36, 80, 160); ........ ......... document.newpage(); //writing in default page txt file document.add(new com.lowagie.text.paragraph("\n")); istream = new fileinputstream(path1); //path1 location of .txt file in = new datainputstream(istream); = new inputstreamreader(in); br = new bufferedreader(is); string strline; while ((strline = br.readline()) != null) { paragraph para = new com.lowagie.text.paragraph(strline + "\n"); para.setalignment(element.align_justified); document.add(new com.lowagie.text.paragraph(strline + "\n")); } br.close(); is.close(); in.close(); istream.close(); document.close(); writer.close(); sorry i'm using lower version of itext because right can't add third party library windchill.this version of itext windchill have in it.
how set font size inside pdf file when writing it.?any helpful.
quite simple :d
fist, change 1 thing:
while ((strline = br.readline()) != null) { paragraph para = new com.lowagie.text.paragraph(strline + "\n"); para.setalignment(element.align_justified); document.add(para); } this way, paragraph justified in document. way did it, changed text alignment of 1 paragaph-object, added new, totally different 1 pdf.
now problem:
can specify font in each paragraph` contructor follows:
paragraph para = new com.lowagie.text.paragraph(strline + "\n", fontfactory.getfont("arial", 14f /*this size, float!*/); the entire documentation of lowagie api can found here.
best regards
Comments
Post a Comment