Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Problem embedding my own font.

Mike I Shaw

2004-03-02


Problem embedding my own font.

Hello IText Guys,

I am having problems making a pdf using an embedded font and then viewing it
using acrobat 6. The font (attached) looks ok and the program I use is just the
Chap0902 example with some very minor mods (below). It works fine with other
fonts but with mine causes acrobat to say...

ole0.bmp

Has anyone seen this problem before / got an idea what the problem is?

All ideas gratefully received, thanks
Mike Shaw

------------------------- modified Chap0902 program -----------------------------

import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.*;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;

public class Chap0902 {
   
    public static void main(String[] args) {
       
        // step 1: creation of a document-object
        Document document = new Document();
       
        try {
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            PdfWriter.getInstance(document, new FileOutputStream("Chap0902.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4: we add content to the document
            //BaseFont bfComic = BaseFont.createFont("c:\\winnt\\fonts\\comicbd.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);

            BaseFont bfComic = BaseFont.createFont("c:\\winnt\\fonts\\UBSWealth.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

           
            Font font = new Font(bfComic, 12);
            String text1 = "abc";
            document.add(new Paragraph(text1, font));
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
            System.err.println(ioe.getMessage());
        }
       
        // step 5: we close the document
        document.close();
    }
}


<<UBSWealth.ttf>>


Attachment: ole0.bmp


Attachment: UBSWealth.ttf
©2008 junlu.com - Jax Systems, LLC, U.S.A.