Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge two Paragraph objects

Tags:

java

itext

I want to insert a piece of text in a PDF which contains bold and not-bold areas, but I do not know how can I do this ?

I'm using iText5 (java).

This is my code:

public class CreatePdf{
   private Font bigFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 12, Font.BOLD, new Color(0, 0, 0));
   private Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 8, Font.NORMAL, new Color(0, 0, 0));

   public void create(){
      Paragraph parag1=new Paragraph("Number: ",bigFont);//This gonna be bold font
      Paragraph parag2=new Paragraph("12", smallFont); //This gonna be normal font

      //Create one paragraph from these two paragraphs. But How ?
   }
}
like image 900
olyanren Avatar asked Dec 17 '22 06:12

olyanren


1 Answers

You can make simpler:

comb.add(parag1);
comb.add(parag2);

The Chunk is not necessary.

like image 120
rics Avatar answered Dec 28 '22 08:12

rics