Reputation: 29
I use the following code to display a line in a PDF file using iText:
Phrase phraseHeader = new Phrase(18, new Chunk("Registration Form "+registrationForm.getRegistrationDate(), FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)));
Paragraph paragraph=new Paragraph(phraseHeader);
paragraph.setAlignment("center");
document.add(paragraph);
If I run this code the pdf file will contain the following:
Registration Form 26-Apr-2013 11:58:20
I want to display the "Registration Form" in a larger font and the date/time in a smaller font, but both should be in the same line. How can I am do this?
Upvotes: 0
Views: 208
Reputation: 3599
This should do the trick:
Phrase phraseHeader = new Phrase();
phraseHeader.add(
new Chunk("Registration Form ",
FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)));
phraseHeader.add(
new Chunk(registrationForm.getRegistrationDate(),
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)));
Paragraph paragraph = new Paragraph(phraseHeader);
Upvotes: 3