我正在尝试从文本pdf页面生成图像。
我正在使用ubuntu 12.04。
以下行在将pdf页面转换为图片时出现错误:
BufferedImage image = page.convertToImage();
堆栈追踪:
java.awt.FontFormatException: Font name not found
at sun.font.TrueTypeFont.init(TrueTypeFont.java:528)
at sun.font.TrueTypeFont.<init>(TrueTypeFont.java:162)
at sun.font.FontManager.createFont2D(FontManager.java:2474)
at java.awt.Font.<init>(Font.java:570)
at java.awt.Font.createFont(Font.java:896)
at org.pdfbox.pdmodel.font.PDTrueTypeFont.drawString(PDTrueTypeFont.java:361)
at org.pdfbox.pdfviewer.PageDrawer.showCharacter(PageDrawer.java:160)
at org.pdfbox.util.PDFStreamEngine.showString(PDFStreamEngine.java:409)
at org.pdfbox.util.operator.ShowText.process(ShowText.java:64)
at org.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:452)
at org.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:215)
at org.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:174)
at org.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:104)
at org.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:657)
at com.demo.controller.web.ProcessTransactionController.getSliderData(ProcessTransactionController.java:182)
at com.demo.controller.web.ProcessTransactionController.processSelectedTransactions(ProcessTransactionController.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
.
.
.
at java.lang.Thread.run(Thread.java:662)
org.pdfbox.exceptions.WrappedIOException: Font name not found
at org.pdfbox.pdmodel.font.PDTrueTypeFont.drawString(PDTrueTypeFont.java:382)
at org.pdfbox.pdfviewer.PageDrawer.showCharacter(PageDrawer.java:160)
at org.pdfbox.util.PDFStreamEngine.showString(PDFStreamEngine.java:409)
at org.pdfbox.util.operator.ShowText.process(ShowText.java:64)
at org.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:452)
at org.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:215)
at org.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:174)
at org.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:104)
at org.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:657)
at com.demo.controller.web.ProcessTransactionController.getSliderData(ProcessTransactionController.java:182)
at com.demo.controller.web.ProcessTransactionController.processSelectedTransactions(ProcessTransactionController.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:185)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:159)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.demo.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:36)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.demo.filter.gzip.GZIPFilter.doFilter(GZIPFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke..