Pdf 使用weblogic server的Solaris上的特殊字符编码问题

Pdf 使用weblogic server的Solaris上的特殊字符编码问题,pdf,character-encoding,solaris,special-characters,apache-fop,Pdf,Character Encoding,Solaris,Special Characters,Apache Fop,我有一个应用程序,它使用fop和xslt生成PDF文件。特殊字符如§?ÐÆ在PDF中显示为? weblogic服务器正在solaris计算机上运行。 我已经试过了 <charset-params> <input-charset> <resource-path>/*</resource-path> <java-charset-name>UTF-8</java-charset-name>

我有一个应用程序,它使用fop和xslt生成PDF文件。特殊字符如
§?ÐÆ
在PDF中显示为

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> 
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");

那里似乎什么也没用。

你设置了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>

/usr/share/fonts/TrueType/core/
/usr/share/fonts/TrueType/dejavu/
/usr/share/fonts/TrueType/liberation/
/usr/share/fonts/TrueType/unifont/


  • 我的服务器是Solaris 5.10 sparc。这条路行吗。如果没有,如何获得合适的字体路径。另外,请告诉我如何在我的web应用程序中提供对该文件的引用。我是否需要在web.xml中注册这个文件,或者需要添加一些java代码来使用这个文件。我是FOP新手,所以对此我不太了解。我尝试使用fopFactory.setUserConfig(新文件(servletContext.getRealPath(“/xml/fo/fop-conf.xml”));在我的pdf生成器类中,使用上述xml,但这不起作用;setUserConfig(新文件(servletContext.getRealPath(“/xml/fo/fop-conf.xml”));FOUserAgent FOUserAgent=fopFactory.newFOUserAgent();setBaseURL(“文件://“+路径);OutputStream out=新java.io.FileOutputStream(pdffile);out=新java.io.BufferedOutputStream(out);Fop Fop=fopFactory.newFop(MimeConstants.MIME_PDF,FousAgent,out);TransformerFactory=TransformerFactory.newInstance();StreamSource st=newstreamsource(servletContext.getResourceAsStream(“/xml/fo/test.xsl”);变压器=工厂新变压器(st);transformer.setParameter(“versionParam”、“2.0”);sourcesrc=newstreamsource(newjava.io.StringReader(getXML(pgmBriefId,name,dept));Result res=新的SAXSult(fop.getDefaultHandler());setOutputProperty(OutputKeys.METHOD,“xml”);setOutputProperty(“{}缩进量”,“2”);transformer.setOutputProperty(OutputKeys.INDENT,“是”);transformer.setOutputProperty(OutputKeys.ENCODING,“UTF-8”);变换(src,res);