Package com.lowagie.examples.fonts.getting

Source Code of com.lowagie.examples.fonts.getting.OpenTypeFont

/*
* $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.fonts.getting;


import com.lowagie.text.LwgDocument;
import com.lowagie.text.LwgFont;
import com.lowagie.text.LwgPageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
import org.geoforge.demo.GfrFileOutputStream;

/**
* Using an Open Type Font (CFF only).
*/
public class OpenTypeFont {
  /**
   * Using oth
   * @param args no arguments needed
   */
  public static void main(String[] args) {
    // step 1
        LwgDocument document = new LwgDocument(LwgPageSize.A4, 50, 50, 50, 50);
        try {
          // step 2
            PdfWriter.getInstance(document, new GfrFileOutputStream("com.lowagie.examples.fonts.getting.OpenTypeFont.pdf"));
            // step 3
            document.open();
            // step 4
            BaseFont bf = BaseFont.createFont("liz.otf", BaseFont.CP1252, true);
            String text = "Some text with the otf font LIZ.";
            document.add(new Paragraph(text, new LwgFont(bf, 14)));
        }
        catch (Exception de) {
            de.printStackTrace();
        }
        // step 5
        document.close();
  }
}
TOP

Related Classes of com.lowagie.examples.fonts.getting.OpenTypeFont

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.