pdf-plugin-structure.dita 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <concept id="pdf-plugin-structure">
  5. <title>PDF plug-in structure</title>
  6. <shortdesc>In cases that require substantial customizations, it is often useful to organize the files in a folder
  7. structure that mimics the hierarchy of the default PDF plug-in.</shortdesc>
  8. <prolog>
  9. <metadata>
  10. <keywords>
  11. <indexterm>languages
  12. <indexterm>adding support for</indexterm></indexterm>
  13. <indexterm>I18N
  14. <indexterm>plug-in</indexterm></indexterm>
  15. <indexterm>PDF
  16. <indexterm>plug-in</indexterm></indexterm>
  17. <indexterm>font-mappings.xml</indexterm>
  18. <indexterm>fonts
  19. <indexterm>PDF</indexterm></indexterm>
  20. <indexterm>PDF
  21. <indexterm>fonts</indexterm></indexterm>
  22. <indexterm>index
  23. <indexterm>PDF</indexterm></indexterm>
  24. <indexterm>Customization directory</indexterm>
  25. </keywords>
  26. </metadata>
  27. </prolog>
  28. <conbody>
  29. <note>For simpler customizations, you may want to structure your plug-in differently, but the information in this
  30. topic may help you to locate the files you need to customize.</note>
  31. <p>The original Idiom plug-in used its own extension mechanism to provide overrides to the PDF transformation. With
  32. this approach, a dedicated <filepath>Customization</filepath> folder within the plug-in was used as a
  33. customization layer to store files that override the default behavior.</p>
  34. <p>While this method is no longer recommended, the same organization principles can be used in custom PDF plug-ins
  35. to facilitate comparisons with the default settings in the base PDF plug-in and make it easier to migrate
  36. customizations to new toolkit versions.</p>
  37. <fig>
  38. <title>Default <filepath>Customization</filepath> folder content</title>
  39. <codeblock>.
  40. ├── build.properties.orig
  41. ├── catalog.xml.orig
  42. └── fo/
  43. ├── attrs/
  44. │ └── custom.xsl.orig
  45. └── xsl/
  46. └── custom.xsl.orig</codeblock>
  47. </fig>
  48. <p>To begin creating a new custom plug-in, you can copy the contents of the customization layer template in
  49. <filepath>plugins/org.dita.pdf2/Customization</filepath> to a new folder that will serve as your new custom
  50. plug-in folder, such as <filepath>plugins/com.company.pdf</filepath>.</p>
  51. <p>To mimic the hierarchy of the default PDF plug-in, you may want to add a <filepath>cfg/</filepath> subfolder and
  52. move the contents of the <filepath>fo/</filepath> folder to <filepath>cfg/fo/</filepath>.</p>
  53. <p>DITA-OT provides template files that you can start with throughout the <filepath>Customization</filepath>
  54. directory structure. These files end in the suffix <codeph>.orig</codeph> (for example,
  55. <filepath>catalog.xml.orig</filepath>). To enable these files, remove the <codeph>.orig</codeph> suffix from the
  56. copies in your new custom plug-in folder. (For example, rename <filepath>catalog.xml.orig</filepath> to
  57. <filepath>catalog.xml</filepath>).</p>
  58. <p>You can then make modifications to the copy in your custom plug-in folder, and copy any other files from the
  59. default PDF plug-in that you need to override, such as the page layouts in
  60. <filepath>layout-masters.xsl</filepath>, or the <filepath>font-mappings.xml</filepath> file that tells your PDF
  61. renderer which fonts to use and where to find them.</p>
  62. <note type="important"> Wherever possible, avoid copying entire XSL files from the PDF2 plug-in to your custom
  63. plug-in. Instead, copy only the specific attribute sets and templates that you want to override. For details, see
  64. <xref keyref="plugin-coding-conventions"/>.</note>
  65. <p>Things you can currently override include:</p>
  66. <ul>
  67. <li>Custom XSL via <filepath>xsl/custom.xsl</filepath> and <filepath>attrs/custom.xsl</filepath></li>
  68. <li>Layout overrides via <filepath>layout-masters.xsl</filepath></li>
  69. <li>Font overrides via <filepath>font-mappings.xml</filepath></li>
  70. <li>Per-locale variable overrides via <filepath>common/vars/[language].xml</filepath></li>
  71. <li>I18N configuration via <filepath>i18n/[language].xml</filepath></li>
  72. <li>Index configuration via <filepath>index/[language].xml</filepath></li>
  73. </ul>
  74. <p>When customizing any of these areas, modify the relevant file(s) in your custom plug-in folder. Then, to enable
  75. the changes in the publishing process, you find the corresponding entry for each file you modified in the
  76. <filepath>catalog.xml</filepath> file.</p>
  77. <p>It should look like this:</p>
  78. <codeblock outputclass="language-xml">&lt;!--uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/--&gt;</codeblock>
  79. <p>Remove the comment markers <codeph>!--</codeph> and <codeph>--</codeph> to enable the change:</p>
  80. <codeblock outputclass="language-xml">&lt;uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/&gt;</codeblock>
  81. <p>Your customization should now be enabled as part of the publishing process.</p>
  82. <fig>
  83. <title>Sample custom plug-in structure</title>
  84. <codeblock>.
  85. ├── plugin.xml
  86. ├── ant-include.xml
  87. └── cfg/
  88. ├── catalog.xml
  89. ├── common/
  90. │ ├── artwork/
  91. │ │ ├── logo.svg
  92. │ └── vars/
  93. │ ├── strings.xml
  94. │ ├── en.xml
  95. └── fo/
  96. ├── attrs/
  97. │ ├── custom.xsl
  98. ├── font-mappings.xml
  99. ├── layout-masters.xsl
  100. └── xsl/
  101. └── custom.xsl</codeblock>
  102. </fig>
  103. <p>When your custom plug-in is installed, the files in its subfolders will override the out-of-the-box settings from
  104. their counterparts in <filepath>org.dita.pdf2/cfg/fo/attrs</filepath> and
  105. <filepath>org.dita.pdf2/xsl/fo</filepath>.</p>
  106. <p>The following topics describe the contents of the base PDF plug-in subfolders and provide additional information
  107. on customizing various aspects of the default PDF output.</p>
  108. </conbody>
  109. </concept>