@李星 你好,想跟你请教个问题:
哈哈,这里能多写点,
ERROR 2015-03-29 00:24:00 [line:68] [cn.com.sinosoft.app.pdf.PdfDocumentGenerator] The document [primarykey=1234567890123456] is failed to generate
<p>
</p>
<p>
pdf生成失败
</p>
<p>
<span>cn.com.sinosoft.app.pdf.exception.DocumentGeneratingException</span>: The document [primarykey=1234567890123456] is failed to generate
</p>
<p>
at cn.com.sinosoft.app.pdf.PdfDocumentGenerator.generate(<span>PdfDocumentGenerator.java:69</span>)
</p>
<p>
at cn.com.sinosoft.test.TestPdfGenerator.test(<span>TestPdfGenerator.java:72</span>)
</p>
<p>
at cn.com.sinosoft.test.TestPdfGenerator.testGenerate(<span>TestPdfGenerator.java:88</span>)
</p>
<p>
at sun.reflect.NativeMethodAccessorImpl.invoke0(<span>Native Method</span>)
</p>
<p>
at sun.reflect.NativeMethodAccessorImpl.invoke(<span>NativeMethodAccessorImpl.java:57</span>)
</p>
<p>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(<span>DelegatingMethodAccessorImpl.java:43</span>)
</p>
<p>
at java.lang.reflect.Method.invoke(<span>Method.java:606</span>)
</p>
<p>
at junit.framework.TestCase.runTest(<span>TestCase.java:176</span>)
</p>
<p>
at junit.framework.TestCase.runBare(<span>TestCase.java:141</span>)
</p>
<p>
at junit.framework.TestResult$1.protect(<span>TestResult.java:122</span>)
</p>
<p>
at junit.framework.TestResult.runProtected(<span>TestResult.java:142</span>)
</p>
<p>
at junit.framework.TestResult.run(<span>TestResult.java:125</span>)
</p>
<p>
at junit.framework.TestCase.run(<span>TestCase.java:129</span>)
</p>
<p>
at junit.framework.TestSuite.runTest(<span>TestSuite.java:255</span>)
</p>
<p>
at junit.framework.TestSuite.run(<span>TestSuite.java:250</span>)
</p>
<p>
at org.junit.internal.runners.JUnit38ClassRunner.run(<span>JUnit38ClassRunner.java:84</span>)
</p>
<p>
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(<span>JUnit4TestReference.java:50</span>)
</p>
<p>
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(<span>TestExecution.java:38</span>)
</p>
<p>
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(<span>RemoteTestRunner.java:459</span>)
</p>
<p>
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(<span>RemoteTestRunner.java:675</span>)
</p>
<p>
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(<span>RemoteTestRunner.java:382</span>)
</p>
<p>
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(<span>RemoteTestRunner.java:192</span>)
</p>
<p>
Caused by: <span>java.lang.RuntimeException</span>: Font 'STSong-Light,BoldItalic' with 'UniGB-UCS2-H' is not recognized.
</p>
<p>
at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(<span>ITextFontResolver.java:511</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(<span>ITextFontResolver.java:40</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(<span>ITextRenderer.java:113</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextRenderer.<init>(<span>ITextRenderer.java:98</span>)
</p>
<p>
at cn.com.sinosoft.app.pdf.factory.ITextRendererObjectFactory.createTextRenderer(<span>ITextRendererObjectFactory.java:71</span>)
</p>
<p>
at cn.com.sinosoft.app.pdf.factory.ITextRendererObjectFactory.makeObject(<span>ITextRendererObjectFactory.java:29</span>)
</p>
<p>
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(<span>GenericObjectPool.java:1140</span>)
</p>
<p>
at cn.com.sinosoft.app.pdf.PdfDocumentGenerator.generate(<span>PdfDocumentGenerator.java:101</span>)
</p>
<p>
at cn.com.sinosoft.app.pdf.PdfDocumentGenerator.generate(<span>PdfDocumentGenerator.java:59</span>)
</p>
<p>
... 21 more
</p>
<p>
Caused by: <span>com.itextpdf.text.DocumentException</span>: Font 'STSong-Light,BoldItalic' with 'UniGB-UCS2-H' is not recognized.
</p>
<p>
at com.itextpdf.text.pdf.BaseFont.createFont(<span>BaseFont.java:714</span>)
</p>
<p>
at com.itextpdf.text.pdf.BaseFont.createFont(<span>BaseFont.java:621</span>)
</p>
<p>
at com.itextpdf.text.pdf.BaseFont.createFont(<span>BaseFont.java:456</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(<span>ITextFontResolver.java:526</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextFontResolver.addCJKFont(<span>ITextFontResolver.java:657</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextFontResolver.addCJKFonts(<span>ITextFontResolver.java:647</span>)
</p>
<p>
at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(<span>ITextFontResolver.java:508</span>)
</p>
<p>
... 29 more
</p>
谢谢!!!
Causedby: java.lang.RuntimeException :Font'STSong-Light,BoldItalic'with'UniGB-UCS2-H'isnotrecognized.
不懂itext,这个是字体问题吧.
中文要加个其他包。你去找看看。
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
STSong-Light,BoldItalic,你看下自己系统有没有这个字体。这个是adobe的仿宋。如果没有,就换成自己系统中有的,比如宋体雅黑这样。
还有把可以po出来的代码po下比较好。
如果是linux系统下呢?其实我原来就是在linux下用的。linux下可以自己安装字体(不同发行版有不同方法),然后用fc-list查看安装的字体。选择对应的就好。
不过adobe的仿宋在pdf理看起来有点淡。选择喜欢的字体就好。
找下有没有STSong-Light ttf格式字体文件放到项目下doc-render/src/test/resources/config/fonts,可以自己加载的...或者换个其他可以找到ttf文件的字体试试版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。