You also need the .afm or .pfm file.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Andrej Virant
> Sent: Thursday, July 17, 2008 11:06 AM
> To: [email protected]
> Subject: [iText-questions] Problems with Adobe Type 1 font for Windows
> 
> Hello,
> 
> I have to use Adobe Type 1 font (.pfb). I use Java 6. When I use this 
> font in application, it has no problems using font, but when 
> I try this 
> when making PDF, it uses default font in instead of one I choose. Can 
> you tell me how to use Adobe Type 1 font with iText PDF 
> creator? Ma code 
> that works wrong is bellow.
> 
> Thank you, Andrej Virant
> 
> 
> 
>     com.lowagie.text.Rectangle dd = new 
> com.lowagie.text.Rectangle(200f, 
> 200f);
> 
>     Document doc = new Document(dd);
> 
>     try {
>       PdfWriter wr = PdfWriter.getInstance(doc, new 
> FileOutputStream("mypdf.pdf"));
>       doc.setMargins(0,0,0,0);
>       doc.open();
> 
>       PdfContentByte cb = wr.getDirectContent();
>       PdfTemplate tp = cb.createTemplate(200f, 200f);
>       DefaultFontMapper mapper = new DefaultFontMapper();
>       mapper.insertDirectory("c:/MyFonts/");
>     
>       Graphics2D g2 = tp.createGraphics(200f, 200f, mapper);
>    
>       File file = new File("MyFonts/NimbusSanDEE_black.pfb");
>       FileInputStream fis = new FileInputStream(file);
>       java.awt.Font font = 
> java.awt.Font.createFont(java.awt.Font.TYPE1_FONT, fis);
> 
>       g2.setFont(font.deriveFont(java.awt.Font.PLAIN, 20f));
>       g2.drawString("Write this text", 10f, 50f);
>     
>       g2.dispose();
>       cb.addTemplate(tp, 0, 0);
>     } catch (Exception e) {
>       e.printStackTrace();
>     }
>     doc.close();
>    
> 


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to