1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
|
---|
3 | <task id="dita2pdf-customization" xml:lang="en">
|
---|
4 | <title>Customizing PDF output</title>
|
---|
5 | <shortdesc>Example of PDF output customization with a custom transformation type.</shortdesc>
|
---|
6 | <taskbody>
|
---|
7 | <steps>
|
---|
8 | <step>
|
---|
9 | <cmd>Create a new plug-in directory <filepath>com.example.print-pdf</filepath> into DITA-OT
|
---|
10 | <filepath>plugins</filepath> directory.</cmd>
|
---|
11 | </step>
|
---|
12 | <step>
|
---|
13 | <cmd>Create a plug-in configuration file <filepath>plugin.xml</filepath>, declare the new
|
---|
14 | transformation type <keyword>print-pdf</keyword> and dependencies.</cmd>
|
---|
15 | <info><fig><codeblock><?xml version='1.0' encoding='UTF-8'?>
|
---|
16 | <plugin id="com.example.print-pdf">
|
---|
17 | <require plugin="org.dita.pdf2"/>
|
---|
18 | <feature extension="dita.conductor.transtype.check" value="print-pdf"/>
|
---|
19 | <feature extension="dita.transtype.print" value="print-pdf"/>
|
---|
20 | <feature extension="dita.conductor.target.relative" file="integrator.xml"/>
|
---|
21 | </plugin></codeblock></fig></info>
|
---|
22 | </step>
|
---|
23 | <step>
|
---|
24 | <cmd>Add an Ant script <filepath>integrator.xml</filepath> to define the transformation
|
---|
25 | type.</cmd>
|
---|
26 | <info><codeblock><?xml version='1.0' encoding='UTF-8'?>
|
---|
27 | <project name="com.example.print-pdf">
|
---|
28 | <target name="dita2print-pdf.init">
|
---|
29 | <property name="customization.dir" location="${dita.plugin.com.example.print-pdf.dir}/cfg"/>
|
---|
30 | </target>
|
---|
31 | <target name="dita2print-pdf" depends="dita2print-pdf.init, dita2pdf2"/>
|
---|
32 | </project></codeblock></info>
|
---|
33 | </step>
|
---|
34 | <step>
|
---|
35 | <cmd>Add a <filepath>cfg/catalog.xml</filepath> file to take custom XSLT stylesheets into
|
---|
36 | use.</cmd>
|
---|
37 | <info><codeblock><?xml version="1.0" encoding="UTF-8"?>
|
---|
38 | <catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
|
---|
39 | <uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
|
---|
40 | <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>
|
---|
41 | </catalog></codeblock></info>
|
---|
42 | </step>
|
---|
43 | <step>
|
---|
44 | <cmd>Add attribute and variable overrides to
|
---|
45 | <filepath>cfg/fo/attrs/custom.xsl</filepath></cmd>
|
---|
46 | <info> <codeblock><?xml version="1.0" encoding="UTF-8"?>
|
---|
47 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
48 | version="2.0">
|
---|
49 | <!-- Change page size to A4 -->
|
---|
50 | <xsl:variable name="page-width">210mm</xsl:variable>
|
---|
51 | <xsl:variable name="page-height">297mm</xsl:variable>
|
---|
52 | </xsl:stylesheet></codeblock></info>
|
---|
53 | </step>
|
---|
54 | <step>
|
---|
55 | <cmd>Add XSLT overrides to <filepath>cfg/fo/xsl/custom.xsl</filepath></cmd>
|
---|
56 | <info>
|
---|
57 | <codeblock><?xml version="1.0" encoding="UTF-8"?>
|
---|
58 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
59 | xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
---|
60 | xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
---|
61 | version="2.0">
|
---|
62 | <!-- Move figure title to top and description to bottom -->
|
---|
63 | <xsl:template match="*[contains(@class,' topic/fig ')]">
|
---|
64 | <fo:block xsl:use-attribute-sets="fig">
|
---|
65 | <xsl:call-template name="commonattributes"/>
|
---|
66 | <xsl:if test="not(@id)">
|
---|
67 | <xsl:attribute name="id">
|
---|
68 | <xsl:call-template name="get-id"/>
|
---|
69 | </xsl:attribute>
|
---|
70 | </xsl:if>
|
---|
71 | <xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
|
---|
72 | <xsl:apply-templates select="*[not(contains(@class,' topic/title ') or contains(@class,' topic/desc '))]"/>
|
---|
73 | <xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
|
---|
74 | </fo:block>
|
---|
75 | </xsl:template>
|
---|
76 | </xsl:stylesheet></codeblock>
|
---|
77 | </info>
|
---|
78 | </step>
|
---|
79 | <step>
|
---|
80 | <cmd>Add variable definition file <filepath>cfg/common/vars/en.xml</filepath> for English to
|
---|
81 | override generated text.</cmd>
|
---|
82 | <info>
|
---|
83 | <codeblock><?xml version="1.0" encoding="UTF-8"?>
|
---|
84 | <vars xmlns="http://www.idiominc.com/opentopic/vars">
|
---|
85 | <!-- Remove dot from list number -->
|
---|
86 | <variable id="Ordered List Number"><param ref-name="number"/></variable>
|
---|
87 | <!-- Change unordered list bullet to an em dash -->
|
---|
88 | <variable id="Unordered List bullet">&#x2014;</variable>
|
---|
89 | </vars></codeblock>
|
---|
90 | </info>
|
---|
91 | </step>
|
---|
92 | </steps>
|
---|
93 | <result id="result_23y_yv3_tf">
|
---|
94 | <p>The plug-in directory should have the layout and files:</p>
|
---|
95 | <codeblock>com.example.print-pdf/
|
---|
96 | cfg/
|
---|
97 | common/
|
---|
98 | vars/
|
---|
99 | en.xml
|
---|
100 | fo/
|
---|
101 | attrs/
|
---|
102 | custom.xsl
|
---|
103 | xsl/
|
---|
104 | custom.xsl
|
---|
105 | catalog.xml
|
---|
106 | integrator.xml
|
---|
107 | plugin.xml</codeblock>
|
---|
108 | </result>
|
---|
109 | <postreq id="postreq_mqj_zz3_tf">
|
---|
110 | <p>Run integration process to install the plug-in and take the <keyword>print-pdf</keyword>
|
---|
111 | transformation type into use.</p>
|
---|
112 | </postreq>
|
---|
113 | </taskbody>
|
---|
114 | </task>
|
---|