DITA-OT输出PDF的样式设计

这里很乱,有空再整理

DITA OT 生成 PDF 中文字体设置

  1. font mapping DITA-OT1.7.5\plugins\org.dita.pdf2\cfg\fo\font-mappings.xml
    <logical-font name="Sans">
      <physical-font char-set="default">
        <font-face>Helvetica, Arial Unicode MS</font-face>
      </physical-font>
      <physical-font char-set="Simplified Chinese">
        <font-face>SimSun</font-face>
      </physical-font>

三类字体有3处要改。

1.8版时这里是:

      <physical-font char-set="Simplified Chinese">
        <font-face>AdobeSongStd-Light</font-face>
      </physical-font>

fop.xconf

DITA-OT1.7.5\plugins\org.dita.pdf2\fop\conf\fop.xconf

缺省纸张大小:

  <default-page-settings height="11.68in" width="8.26in"/>

应该是11.69"x8.27"

      <fonts>
        <!-- automatically detect operating system installed fonts -->
        <directory>C:\Windows\Fonts</directory>
        <auto-detect/>

        <!-- register a particular font -->
           <font kerning="yes"
                 embed-url="file:///C:/Windows/Fonts/simsun.ttc"  sub-font="SimSun" 
                 encoding-mode="auto">
               <font-triplet name="SimSun" style="normal" weight="normal"/>
           </font>
      </fonts>

Adobe otf 字体目前不支持,OT会报错;TTC字体可以用,但必须指明sub-font。现在都不需要生成 字体 metrics 了。

character range

DITA-OT1.7.5\plugins\org.dita.pdf2\cfg\fo\i18n\zh_CN.xml
    <alphabet char-set="Simplified Chinese">
       <character-set>
          <character-range>
         <start include="yes">&#x4e00;</start>
         <end include="yes">&#x9fff;</end>
      </character-range>
          <character-range>
         <start include="yes">&#x3400;</start>
         <end include="yes">&#x4dff;</end>
      </character-range>
          <character-range>
         <start include="yes">&#x0100;</start>
         <end include="yes">&#xffe5;</end>
      </character-range>
       </character-set>
    </alphabet>

三段中的最后一段是中文等宽标点符号的范围,字体里都有,但原来的范围是错的,要改到0xffe5, 也有说 ff60 或 ff20 的。于是OT会去找TIMES字体来用,就会找不到,改了之后就会去中文字体中找了。

xml:lang

最后是所有DITA文件中都必须指明这个属性,每一个文件都要设。是中文就设zh_CN,这样OT就会去找中文的设置来用。生成PDF才会没有问题。

上面这句有问题。必须设置成 zh-CN,这样OT才能认。是个Bug,但直到1.7.5也没改。

基本页面设置

__frontmatter__owner__container 可能是定义了owner部分的block DITA-OT1.8\plugins\org.dita.pdf2\cfg\fo\attrs\front-matter-attr.xsl 这个文件里定义了这个container的位置和大小!

DITA-OT1.8\plugins\org.dita.pdf2\cfg\fo\attrs\front-matter-attr.xsl

<xsl:attribute-set name="__frontmatter__title" use-attribute-sets="common.title">
        <xsl:attribute name="space-before">40mm</xsl:attribute>

原来是80mm

<xsl:attribute-set name="__frontmatter">
        <xsl:attribute name="text-align">right</xsl:attribute>
    </xsl:attribute-set>

原来是center

把这两项放到custom.xsl里面,可行。

__frontmatter__owner__container 是一个容器,里面可以放block,它自己也可以放在其他block里面,可以定义绝对位置,并且有z-index选项,所以不会撑大包含它的block。

这个要起作用,必须放在frontmatter里的flow里面

相应template的attr-set也可以都写在customs.xsl里面

再来一个block-container,单加一个break-before :page来进行手工分页。可以出在封面背后,写上文字。采用了jjv写在custom.xml里面的方法。

这个方面会在header上出现preface的显示,要想办法去掉。

再试验用frontmatter里 preface/notices的方面,但它们都会自动出现在第三页, force-page-count设为Auto可以解决。