Apache FOP Display ### with SunSim

I support a program that uses Apache FOP to print PDF documents. There were several complaints about Chinese characters that appeared as "####". I found there an existing thread about this problem and did some research on my side.

http://apache-fop.1065347.n5.nabble.com/Chinese-Fonts-td10789.html

I have uming.tff language files installed on my system. Unlike the person in this thread, I still get "####".

From now on, has anyone seen a job that will allow you to print complex characters in a PDF using Apache FOP?

Ryan

+3
source share
1 answer

PDF, FOP, ( , , , , , ).

, , FOP, - :

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="one">
            <fo:region-body />
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="one">
        <fo:flow flow-name="xsl-region-body">
            <!-- a block of chinese text -->
            <fo:block>博洛尼亚大学中国学生的毕业论文</fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

, FOP , :

org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "?" (0x535a) not available in font "Helvetica".
...

- FO FOP Helvetica, Base-14 fonts ( , , ).

, ; , , PDF "#" .

1: FO

( ), font-family, .

font-family , , , fo:page-sequence; , font-family fo:block fo:inline.

, ( , ):

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="one">
            <fo:region-body />
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="one">
        <fo:flow flow-name="xsl-region-body">
            <!-- a block of chinese text -->
            <fo:block font-family="SimSun">博洛尼亚大学中国学生的毕业论文</fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

, !

org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "SimSun,normal,400" not found. Substituting with "any,normal,400".
org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "?" (0x535a) not available in font "Times-Roman".
...

FOP , "SimSun" , Base-14 (Times-Roman), , PDF - "#" .

2. FOP

FOP conf/fop.xconf ; .

XML , /fop/renderers/renderer[@mime = 'application/pdf']/fonts/ ( renderer mime, , ):

<?xml version="1.0"?>
<fop version="1.0">
  ...
  <renderers>
    <renderer mime="application/pdf">
      ...
      <fonts>

        <!-- specific font mapping -->
        <font kerning="yes" embed-url="/Users/furini/Library/Fonts/SimSun.ttf" embedding-mode="subset">
          <font-triplet name="SimSun" style="normal" weight="normal"/>
        </font>

        <!-- "bulk" font mapping -->
        <directory>/Users/furini/Library/Fonts</directory>

      </fonts>
      ...
    </renderer>
    ...
  </renderers>
</fop>

(, , , , ,...), , , , PDF .

, : , FO .

, ; , FOP , "" (, "SimSun, italic, 400" FOP , "SimSun, normal, 400", ).

, .

3: FOP,

FOP , -c, , :

$ fop -c /path/to/our/fop.xconf input.fo input.pdf

Java (. FOP):

fopFactory.setUserConfig(new File("/path/to/our/fop.xconf"));

, , PDF .

FOP , :

org.apache.fop.cli.Main startFOP
SEVERE: Exception org.apache.fop.apps.FOPException: Failed to resolve font with embed-url '/Users/furini/Library/Fonts/doesNotExist.ttf'

, FOP , ;

  • url
+9

All Articles