Use the encoding "Symbol" for the Symbol font.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of burma
> Sent: Friday, April 30, 2004 2:07 PM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] Cannot get glyphs rendering from 
> the Symbol Font into the PDF file
> 
> 
> I face the following problem when I generate PDF file  from 
> PDFGraphics2D with Symbol font embedded
> I render unicode characters from  Symbol font that can be 
> displayed on a 
> JFrame but I get nothing in the generated PDF file. (code 
> below).  I'm 
> using  the last iText version on a windows platform with jdk1.4.2..
> 
> Could you please give me some hint on why is this happening.
> 
> Thanks
> Emmanuel D.
> 
> **************************************************************
> *********
> import java.awt.*;
> import javax.swing.*;
> import java.awt.event.*;
> import java.io.*;
> import java.util.*;
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.*;
> 
> class TestFont extends JFrame {
> 
>     int h=170;
>     int w=225;
> 
>     public TestFont() {
>         addWindowListener(
>             new WindowAdapter() {
>             public void windowClosing(WindowEvent we) {
>                 generatePDF();
>                 System.exit(0);
>             }
>         });
>         setSize(w,h);
>         show();
>     }
> 
>     public void paint(Graphics g1) {
>         g1.setFont(new java.awt.Font("Symbol", 
> java.awt.Font.PLAIN, 12));
>         String sDisplayable = "\u0391\u0392\u0393\u0394\u0395\u0396";
>        g1.drawString(sDisplayable,50,50);
>     }
> 
>     void generatePDF() {
> 
>         DefaultFontMapper defaultFontMapper = new DefaultFontMapper();
>         defaultFontMapper.insertDirectory("c:\\winnt\\fonts");
> 
>         HashMap hmBaseFonts = defaultFontMapper.getMapper();
>         Iterator itr = hmBaseFonts.values().iterator();
>         while (itr.hasNext()) {
>             DefaultFontMapper.BaseFontParameters bf = 
> (DefaultFontMapper.BaseFontParameters) itr.next();
>             bf.encoding = com.lowagie.text.pdf.BaseFont.IDENTITY_H;
>             // bf.encoding = 
> com.lowagie.text.pdf.BaseFont.CP1252;  // 
> does not work neither
>         }
> 
>         com.lowagie.text.Rectangle rPage = new 
> com.lowagie.text.Rectangle(w, h);
>         Document document = new Document(rPage, 0.0f, 0.0f, 
> 0.0f, 0.0f);
>         try {
>             PdfWriter writer = PdfWriter.getInstance(document, new 
> FileOutputStream("testfont.pdf"));
>             document.open();
>             PdfContentByte cb = writer.getDirectContent();
>             Graphics2D g2 = cb.createGraphics(w, h, 
> defaultFontMapper);
>             paint(g2);
>             g2.dispose();
>             document.close();
>             System.out.println("testfont.pdf successfully 
> generated!!!");
>         }
>         catch(Exception e) {
>             System.out.println("failed to generate testfont.pdf");
>         }
>     }
> 
>     // Main
>     public static void main(String[] s) {
>         new TestFont();
>     }
> }
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... 
> Oracle 10g. 
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to