0

我有一個使用fop和xslt生成PDF文件的應用程序。在PDF中,特殊字符§£?ÐÅÆ顯示爲????使用weblogic服務器的Solaris上的特殊字符編碼問題

weblogic服務器在solaris機器上運行。 我已經嘗試與

<charset-params> 
    <input-charset> 
     <resource-path>/*</resource-path> 
     <java-charset-name>UTF-8</java-charset-name> 
    </input-charset> 
    <charset-mapping> 
    <iana-charset-name>UTF-8</iana-charset-name> 
    <java-charset-name>UTF-8</java-charset-name> 
</charset-mapping>  
</charset-params> 

weblogic.xml

我也試圖與

transformer.setOutputProperty(OutputKeys.METHOD, "xml"); 
      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); 
      transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 
      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); 

似乎沒有任何要在那裏工作。

回答

0

您是否設置了fop以查找包含這些字符的字體?例如,在Solaris 11 使用FOP(雖然不是與WebLogic),我不得不設置的字體路徑在FOP-conf.xml中:

<?xml version="1.0"?> 
<!-- NOTE: This is the version of the configuration --> 
<fop version="1.0"> 
    <renderers> 
    <renderer mime="application/pdf"> 
     <fonts> 
     <!-- register all the fonts found in a directory --> 
     <directory>/usr/share/fonts/TrueType/core/</directory> 
     <directory>/usr/share/fonts/TrueType/dejavu/</directory> 
     <directory>/usr/share/fonts/TrueType/liberation/</directory> 
     <directory>/usr/share/fonts/TrueType/unifont/</directory> 

     <!-- register all the fonts found in a directory and all of its sub directories (use with care) --> 
     <!-- directory recursive="true">C:\MyFonts2</directory --> 

     <!-- automatically detect operating system installed fonts --> 
     <auto-detect/> 
     </fonts> 
    </renderer> 

    <renderer mime="application/postscript"> 
     <fonts> 
     <directory>/usr/share/fonts/X11/Type1/</directory> 
     <directory>/usr/share/ghostscript/fonts/</directory> 
     <directory>/usr/share/fonts/TrueType/core/</directory> 
     <directory>/usr/share/fonts/TrueType/dejavu/</directory> 
     <directory>/usr/share/fonts/TrueType/liberation/</directory> 
     <directory>/usr/share/fonts/TrueType/unifont/</directory> 
     </fonts> 
    </renderer> 
</renderers> 
</fop> 

(字體路徑將是舊版本的Solaris不同。 )

有關詳細信息,請參閱:

+0

我的服務器是Solaris 5.10 sparc。這條道路會好嗎?如果沒有,如何獲得適當的字體路徑。另外,請告訴我如何在我的Web應用程序中提供對此文件的引用。我需要在web.xml中的某個地方註冊這個文件,或者需要添加一些java代碼來使用它。 – saurabh 2011-05-06 11:09:59

+0

我是新來的FOP,所以我對此沒有太多的想法。我試着用fopFactory.setUserConfig(new File(servletContext.getRealPath(「/ xml/fo/fop-conf.xml」)));在我的PDF生成器類,並使用上述的XML,但沒有奏效。 – saurabh 2011-05-06 12:12:59

+0

以下是我的代碼.... – saurabh 2011-05-06 12:13:48