/*
* $Id$
*
* This code is part of the 'iText Tutorial'.
* You can find the complete tutorial at the following address:
* http://itextdocs.lowagie.com/tutorial/
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* itext-questions@lists.sourceforge.net
*/
package com.lowagie.examples.objects;
import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.LwgDocument;
import com.lowagie.text.LwgFont;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
/**
* Selects the appropriate fonts that contain the glyphs needed to render text correctly.
*/
public class DifferentFonts {
/**
* Using FontSelector.
* @param args no arguments needed
*/
public static void main(String[] args) {
try {
// step 1
LwgDocument document = new LwgDocument();
// step 2
PdfWriter.getInstance(document, new FileOutputStream("differentfonts.pdf"));
// step 3
document.open();
// step 4
Paragraph p = new Paragraph();
p.add(new Chunk("This text is in Times Roman. This is ZapfDingbats: ", new LwgFont(LwgFont.TIMES_ROMAN, 12)));
p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new LwgFont(LwgFont.ZAPFDINGBATS, 12)));
p.add(new Chunk(". This is font Symbol: ", new LwgFont(LwgFont.TIMES_ROMAN, 12)));
p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new LwgFont(LwgFont.SYMBOL, 12)));
document.add(new Paragraph(p));
// step 5
document.close();
}
catch(Exception de) {
de.printStackTrace();
}
}
}