I'm using iText to generate PDF on the fly in a servlet running under Tomcat 4.0.3. The PDF document requires that an image file and True Type font file be packaged with the class that creates the PDF. In my development environment where the image and font files are read directly from the file system, everything works just fine. In my production environment (UNIX), where the PDF writing class, font and image files are packaged in a jar, I get a division by zero error as shown in the stack trace at the end of this message.
Here's the java code for creating the font: BaseFont ocra = null; ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL ocraURL = cl.getResource("com/qec/util/fonts/OCRAN.TTF"); if (ocraURL != null) { byte[] bytes = new byte[ocraURL.openConnection().getContentLength()]; ocraURL.openStream().read(bytes); ocra = BaseFont.createFont("OCRAN.TTF", BaseFont.WINANSI, BaseFont.EMBEDDED, BaseFont.CACHED, bytes, null); } Since my ultimate goal was to make this code reusable outside of servlets, the class which contains the iText code and the required font and image files are packaged with the servlet in a jar file which is placed in the WEB-INF/lib directory of my web application. I know that the ClassLoader.getResource() code works, because I load an image file using the same technique. Am I incorrect in thinking that embedded True Type fonts can be used in this fashion outside of the Windows environment? Any insight into this problem is greatly appreciated. Jeff Here's the previously mentioned stack trace: ExceptionConverter: java.lang.ArithmeticException: / by zero at com.lowagie.text.pdf.TrueTypeFont.getFontDescriptor(Unknown Source) at com.lowagie.text.pdf.TrueTypeFont.writeFont(Unknown Source) at com.lowagie.text.pdf.FontDetails.writeFont(Unknown Source) at com.lowagie.text.pdf.PdfWriter.close(Unknown Source) at com.lowagie.text.pdf.PdfDocument.close(Unknown Source) at com.lowagie.text.Document.close(Unknown Source) at com.qec.util.InvoiceWriter.writePdf(InvoiceWriter.java:103) at com.qec.offsite.servlet.InvoiceServlet.doInvoiceAsPDF(InvoiceServlet.java:106) at com.qec.offsite.servlet.InvoiceServlet.processRequest(InvoiceServlet.java:51) at com.qec.offsite.servlet.InvoiceServlet.doGet(InvoiceServlet.java:39) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at com.qec.offsite.servlet.AbstractOffsiteServlet.service(AbstractOffsiteServlet.java:60) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.ja va:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429) at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495) at java.lang.Thread.run(Thread.java:484) _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions