pdf-plugin-structure.dita 6.2 KB

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