To read a file from a jar as a resource, try the following :

                try {
                        // name is the filename of the font. eg. verdana.ttf
                        // or fully qualified like "/my/own/package/verdana.ttf"
                        // if the file is in another package.
                        InputStream input = this.getClass().getResourceAsStream(name);
                        ByteArrayOutputStream font = new ByteArrayOutputStream();
                        byte[] buffer = new byte[8192];
                        int length = 0;
                        while ((length = input.read(buffer)) != -1) {
                                font.write(buffer, 0, length);
                        }
                        // do what you want with the buffer "font" containing the ... 
eh... font.
                        // eg. font.toByteArray();
                } catch (IOException e) {
                        throw new NestedException(e);
                }

Hubert

From: "Alex Potter" <[EMAIL PROTECTED]>
To: "Dennis Meyer" <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
Subject: Re: [iText-questions] BARCODE: com.lowagie.text.DocumentException: Helvetica not found as resource
Date: Thu, 3 Jul 2003 15:53:00 +0100


Hi

> I'm using iText with the 128Barcode. It's a littlebit strange, but I get
the
> following Exception:
>
> Helvetica not found as resource. (The *.afm files must exist as resources
in
> the package com.lowagie.text.pdf.fonts)


Where have you put the jar? In WEB-INF/lib?
Sounds to me like its not in the classpath.....

HTH

Alex



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous ! http://search.msn.fr/worldwide.asp




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to