Use the very latest version 1.1. There was a concurrency problem in TTF 
Identity-H fonts. 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Tomas Hansson
> Sent: Wednesday, November 17, 2004 11:21 PM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] IOException when trying to access font
> 
> I have a servlet that generates PDF reports based on some data in a
> database.  I am using the Arial font 
> (c:/windows/fonts/arial.ttf).  While
> stress-testing this servlet (>10 simultaneous connections), I am
> occasionally getting a java.io.IOException: Bad file descriptor.
> 
> To alleviate this problem, I was trying to pre-load the font 
> in the init
> method of the servlet (see below) but I am still getting this 
> exception when
> closing the PDF document.  Any suggestions on how to change 
> the code to
> avoid this problem would be very welcome!
> 
> Here is the init method:
>     private static final String FONT = "c:/windows/fonts/arial.ttf";
> 
>     /** Arial arialPlain - plain. */
>     private Font arialPlain;
>     
>     /** Arial arialPlain - bold. */
>     private Font arialBold;
> 
>     public void init() {
>         try {
>             BaseFont bf =
>                 BaseFont.createFont(FONT, BaseFont.IDENTITY_H,
>                 BaseFont.EMBEDDED);
>             arialPlain  = new Font(bf , FONT_SIZE);
>             arialBold = new Font(bf, FONT_SIZE, Font.BOLD);
>         } catch (IOException e) {     
>             e.printStackTrace(System.err);
>         } catch (DocumentException e) {     
>             e.printStackTrace(System.err);
>         }
>     }
> 
> And the main method is fairly straight forward as in:
> 
>               ByteArrayOutputStream ba = new ByteArrayOutputStream();
> 
>             // Set document margins
>             Document document = new Document(PageSize.A4,
>                 PDFDOC_MARGIN, PDFDOC_MARGIN, PDFDOC_MARGIN, 
> PDFDOC_MARGIN);
>             
>             // Use the Arial arialPlain and embedd it
>             // Should give us basic UTF-8 support for most characters
>             PdfWriter.getInstance(document, ba);
> 
>               document.open();
> 
>               ...
>                   Paragraph para = new Paragraph(
>                     new Chunk("Assessment/Évaluation:", arialBold));
>                 document.add(para);
>               ...
> 
>               document.close();
> 
> 
> --
> Tomas Hansson
> mailto:[EMAIL PROTECTED]
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: InterSystems CACHE
> FREE OODBMS DOWNLOAD - A multidimensional database that combines
> robust object and relational technologies, making it a perfect match
> for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to