How to Build PDF format HornetQ User's Manual in Chinese

Version 3

    HornetQ  now provides Chinese version documents alongside its English version.  However it only includes HTML format Chinese documents in its  distribution bundle. To get the PDF format Chinese documents, you need  to manually build it. Here are the steps.


    1. Download the  HornetQ source from HornetQ's SVN repository trunk:


    svn co http://anonsvn.jboss.org/repos/hornetq/trunk <your HornetQ dir>



    2. Get a Chinese  font. Fonts are often copyrighted. For that reason HornetQ doesn't provide  any Chinese fonts in its repository. You have to get a Chinese font in  order to build the documents.


    HornetQ uses  Apache FOP to render fonts into PDF files. It supports several font  types including TrueType and TrueType Collection. Chinese fonts are  often TrueType fonts (.ttf) or TrueType  Collection fonts (.ttc).


    Here we use  TrueType fonts to illustrate. Suppose your Chinese font is in the  following path

     /home/howard/tmp/fonts/simkai.ttf





    3. Register the  font. Once you get the font file, you need to register it with FOP in  the configuration file. Open

    <your HornetQ dir>/lib/docbook-support/support/fop-conf/fop.xconf





    and add the  following within the <fonts> node:



    <font embed-url="file:///home/howard/tmp/fonts/simkai.ttf">
          <font-triplet name="KaiTi" style="normal" weight="normal"/>
          <font-triplet name="KaiTi" style="italic" weight="normal"/>
    </font>





    where "KaiTi"  is the font name.


    4. Use the registered font in the  style file. Open


    <your HornetQ dir>/lib/docbook-support/styles/zh/fopdf.xsl





    and add the  following to the beginning inside the <xsl:stylesheet> node, immediately after the <import> node:



    <xsl:param name="body.font.family">KaiTi</xsl:param> 
    <xsl:param  name="title.font.family">KaiTi</xsl:param>
    <xsl:param  name="monospace.font.family">KaiTi</xsl:param>





    In addition, you  also need to change the page title section (within node <xsl:template  name="book.titlepage.recto">) to apply the right font, like the  following:



        <!--########## Custom Title Page -->
         <xsl:template name="book.titlepage.recto">
            ... ...
                <xsl:if test="bookinfo/title">
                   <fo:block  font-family="KaiTi" font-size="22pt" padding-before="10mm">
                        <xsl:value-of select="bookinfo/title"/>
                    </fo:block>
               </xsl:if>
                <xsl:if test="bookinfo/subtitle">
                   <fo:block  font-family="KaiTi" font-size="18pt" padding-before="10mm">
                        <xsl:value-of select="bookinfo/subtitle"/>
                    </fo:block>
               </xsl:if>
                <xsl:if test="bookinfo/releaseinfo">
                    <fo:block font-family="KaiTi" font-size="12pt"
                        padding="10mm"><xsl:value-of select="bookinfo/releaseinfo"/>
                    </fo:block>
               </xsl:if>
                <xsl:if test="bookinfo/copyright">
                   <fo:block  font-family="KaiTi" font-size="12pt"
                        padding="10mm">                                    
                        <xsl:apply-templates select="bookinfo/copyright"
                           mode="titlepage.mode"/>
                   </fo:block>
                </xsl:if>
            ... ...




    5. Build the  document.


    cd <your HornetQ dir>/docs/user-manual
    ./build.sh  lang.docpdf -Dlang=zh




    You will find the  document at


    <your HornetQ  dir>/docs/user-manual/build/zh/pdf/HornetQ_UserManual.pdf





    Additionally you  can build the quick-start guide with the following command:


    cd <your HornetQ dir>/docs/quickstart-guide
    ./build.sh  lang.docpdf -Dlang=zh





    and the document  is generated at


    <your HornetQ  dir>/docs/user-manual/build/zh/pdf/HornetQ_QuickStartGuide.pdf





    For more  details about Apache Fop fonts configuration, please visit


    http://xmlgraphics.apache.org/fop/0.95/fonts.html