Salve galera, precisava de uma ajuda, estou fazendo um codigo que pega um arquivo txt e tranforma em PDF, só que algumas palavras eu queria que aparececem em negrito, para isso eu usei as tags como no html para saber onde comeca e acaba o negrito da frase, e fiz o seguinte codigo;
Phrase myPhrase = new Phrase();
String str;
int inicioBold = 0;
int fimBold = 0;
while((str = in.readLine()) != null)
{
System.out.println(""+str);
if (str.indexOf("<b>") > -1) {
inicioBold = str.indexOf("<b>");
if (inicioBold > 0) {
fimBold = str.indexOf("</b>");
if (fimBold == -1) {
fimBold = str.length();
}
}
int num = 0;
for(num=1; num<10; num++){
System.out.println("inicioBold: "+inicioBold);
System.out.println("fimBold : "+fimBold);
myPhrase = new Phrase(getTam_leading(), str.substring(0,inicioBold), new Font(Font.COURIER, getTam_Fonte(), Font.NORMAL));
myPhrase.add(new Phrase(getTam_leading(), str.substring(inicioBold+3, fimBold), new Font(Font.COURIER, getTam_Fonte(), Font.BOLD)));
myPhrase.add(new Phrase(getTam_leading(), str.substring(fimBold+4,str.length()), new Font(Font.COURIER, getTam_Fonte(), Font.NORMAL)));
str = str.replace('<', ' ');
}
documentPDF.add(myPhrase);
} else {
linhas++;
documentPDF.add(new Phrase(getTam_leading(), str +"\n", FontFactory.getFont("Courier", getTam_Fonte(), getFonte(), getCor())));
}
Só que para as frases que contem mais de uma ocorencia de ele transforma a primeira e ignora as demais, alguem pode me dar uma ajudinha ai?
Att, Zmovirzynski