Jump to content
We've recently updated our Privacy Statement, available here ×

Cannot locate pdf font when exporting to pdf


Recommended Posts

By: r pelgrim - robinpg

Cannot locate pdf font when exporting to pdf

2003-03-05 02:06

I try to generate a pdf-report (using a servlet in Tomcat). This works fine when I just start Tomcat. When starting Tomcat in Eclipse the following error occurs and I cannot find out where to place itext.jar and jasperreports.jar to let it work.

 

hope somebody can help,

 

Robin

 

 

*************************************************************************

* WARNING: Failure using Thread.currentThread().getContextClassLoader() *

* in JRLoader class. Using JRLoader.class.getClassLoader() instead. *

*************************************************************************

dori.jasper.engine.JRException: Could not load font from location : Times-Roman

at dori.jasper.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:1006)

at dori.jasper.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:346)

at dori.jasper.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:295)

at dori.jasper.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:217)

at dori.jasper.engine.JasperExportManager.exportReportToPdfStream(JasperExportManager.java:166)

at com.ie.web.reports.ReportGenerator.streamReportPDF(ReportGenerator.java:108)

at ReportServlet.doService(ReportServlet.java:110)

at ReportServlet.doGet(ReportServlet.java:46)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:527)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1040)

at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1151)

at java.lang.Thread.run(Thread.java:536)

dori.jasper.engine.JRException: Could not load font from location : Times-Roman

at dori.jasper.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:1006)

at dori.jasper.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:346)

at dori.jasper.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:295)

at dori.jasper.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:217)

at dori.jasper.engine.JasperExportManager.exportReportToPdfStream(JasperExportManager.java:166)

at com.ie.web.reports.ReportGenerator.streamReportPDF(ReportGenerator.java:108)

at ReportServlet.doService(ReportServlet.java:110)

at ReportServlet.doGet(ReportServlet.java:46)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:527)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)

at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1040)

at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1151)

at java.lang.Thread.run(Thread.java:536)

 

 

 

 

By: Teodor Danciu - teodord

RE: Cannot locate pdf font when exporting to pdf

2003-03-05 09:31

 

Hi,

 

I heard this happens in a very arbitrary way

on Unix machines.

 

Are you using iReport?

 

Thank you,

Teodor

 

 

 

 

 

By: r pelgrim - robinpg

RE: Cannot locate pdf font when exporting to pdf

2003-03-06 05:56

Hi,

 

For now it's running on a Windows machine..

 

I wonder how the resources are found by:

URL url = classLoader.getResource(location);

where location is only the font name without path.

 

Where is the link between resource location (comlowagietextpdffontsfontname.afm) in the jar file and the fontname?

 

I am using iReport.

 

Thanks,

 

Robin

 

 

 

 

By: r pelgrim - robinpg

RE: Cannot locate pdf font when exporting to pdf

2003-03-06 06:01

Hi,

 

For now it's running on a Windows machine..

 

I wonder how the resources are found by:

URL url = classLoader.getResource(location);

where location is only the font name without path.

 

Where is the link between resource location (comlowagietextpdffontsfontname.afm) in the jar file and the fontname?

 

I am using iReport.

 

Thanks,

 

Robin

 

 

 

 

By: r pelgrim - robinpg

RE: Cannot locate pdf font when exporting to pdf

2003-03-06 08:08

Hi,

when using 'classLoader.getResource("com/lowagie/text/pdf/fonts/Times-Roman.afm")' i.s.o. 'classLoader.getResource("Times-Roman")' the correct url is found!

 

isn't this a better way to retrieve the standard lowagie font resources?

 

Robin

 

 

 

 

By: Teodor Danciu - teodord

RE: Cannot locate pdf font when exporting to pdf

2003-03-13 13:46

 

Hi,

 

We should not get to such work-arounds.

I was not able to track this yet.

It is a weird problem that appears sporadically.

Hard to reproduce and explain.

 

Normally, iText should recognize its own built-in

fonts.

 

Thank you,

Teodor

 

 

 

 

 

By: Larry Settle - l_settle

RE: Cannot locate pdf font when exporting to pdf

2003-03-24 10:58

I recently had a very similar problem. My environment is:

Win2K Pro

Eclipse 2.0.2

Jetty 4.1.2

j2sdk1.4.1_01

 

When I run the environment from the command line all is well. When I run from Eclipse I was unable to locate various PDF fonts.

 

It turns out the problem is not in locating the font, but

rather the character set encoding for the font. The

problem is caused by setting up the Eclipse runtime environment incorrectly. The following solved the problem for me.

 

In Eclipse goto Run, Run.. and select your launch configuration.

Select the Classpath tab.

Then select the bootstrap classes tab.

Uncheck the use default class path.

Click add external Jars..

In the file dialog navigate to your JDK1.4.1 jre/lib directory and select charsets.jar. This should add it to the classes that will be loaded by the bootstrap loader.

 

There are only 16 built-in character set encodings and

they are in rt.jar. The charsets.jar adds many more encodings via the standard SPI mechanism. The bootstrap loader invoked from the command line will

automatically make the extra encodings available.

Eclipse does not load the charsets.jar file by default

so it does not install the extended charset encodings.

 

The IText library used by JasperReports intercepts

an exception thrown by the runtime and reports the

font is not available. Actually the font is available but

the requested encoding is not. In my case I had a

character encoding of "Cp1250". That character set

is only in the extended character sets not the standard.

Changing to "Cp1252" will circumvent the problem because it is in the standard character sets (they are

in rt.jar). But adding the charsets.jar to the bootstrap

classes will make your Eclipse launches and command

line launches agree on the installed character sets.

 

I hope this solves your problem as well.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...