import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfWriter;
public class PhraseWithSeveralChunksAndDifferentFontsPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("PhraseWithSeveralChunksAndDifferentFontsPDF.pdf"));
document.open();
Phrase phrase6 = new Phrase("I have several Chunks.");
Chunk chunk = new Chunk("Font: ");
phrase6.add(chunk);
phrase6.add(new Chunk("Helvetica", FontFactory.getFont(FontFactory.HELVETICA, 12)));
phrase6.add(chunk);
phrase6.add(new Chunk("Times New Roman", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
phrase6.add(chunk);
phrase6.add(new Chunk("Courier", FontFactory.getFont(FontFactory.COURIER, 12)));
phrase6.add(chunk);
phrase6.add(new Chunk("Symbol", FontFactory.getFont(FontFactory.SYMBOL, 12)));
phrase6.add(chunk);
document.add(Chunk.NEWLINE);
phrase6.add(new Chunk("ZapfDingBats", FontFactory.getFont(FontFactory.ZAPFDINGBATS, 12)));
document.add(phrase6);
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
itext.zip( 1,748 k)