pdf-customization-approaches.dita 6.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_customization_approaches">
  5. <title>PDF customization approaches</title>
  6. <titlealts>
  7. <navtitle>Customization approaches</navtitle>
  8. </titlealts>
  9. <shortdesc>Various methods may be used to customize the PDF output that DITA Open Toolkit produces. Each of these
  10. approaches have advantages and shortcomings that should be considered when preparing a customization
  11. project.</shortdesc>
  12. <prolog>
  13. <metadata>
  14. <keywords>
  15. <indexterm>PDF
  16. <indexterm>customizing, best practices</indexterm></indexterm>
  17. <indexterm>upgrading
  18. <indexterm>default plug-ins</indexterm></indexterm>
  19. <indexterm>upgrading
  20. <indexterm>PDF</indexterm></indexterm>
  21. </keywords>
  22. </metadata>
  23. </prolog>
  24. <conbody>
  25. <note>Some of these methods are considered “anti-patterns” with disadvantages that outweigh their apparent appeal.
  26. In most cases, you should create a custom PDF plug-in.</note>
  27. <section id="why_not_edit_default_files">
  28. <title>Why not edit default files?</title>
  29. <p>When first experimenting with PDF customization, novice users are often tempted to simply edit the default
  30. <filepath>org.dita.pdf2</filepath> files in place to see what happens.</p>
  31. <p>As practical as this approach may seem, the DITA-OT project does not recommend changing any of the files in the
  32. default plug-ins.</p>
  33. <p>While this method yields quick results and can help users to determine which files and templates control
  34. various aspects of PDF output, it quickly leads to problems, as any errors may prevent the toolkit from
  35. generating PDF output.</p>
  36. <note type="warning">Any changes made in this fashion would be overwritten when upgrading to newer versions of
  37. DITA-OT, so users that have customized their toolkit installation in this way are often “stuck” on older
  38. versions of the toolkit and unable to take advantage of improvements in recent versions of DITA-OT.</note>
  39. </section>
  40. <section id="the_customization_folder">
  41. <title>Using the <filepath>Customization</filepath> folder</title>
  42. <indexterm>deprecated features
  43. <indexterm><filepath>Customization</filepath> folder</indexterm></indexterm>
  44. <indexterm>Customization directory</indexterm>
  45. <p>The original Idiom plug-in used its own extension mechanism to provide overrides to the PDF transformation.
  46. With this approach, a dedicated folder within the plug-in is used to store customized files.</p>
  47. <p>Files in the <filepath>org.dita.pdf2/Customization</filepath> folder can override their default counterparts,
  48. allowing users to adjust certain aspects of PDF output without changing any of the plug-in’s default files, or
  49. specifying additional parameters when generating output.</p>
  50. <note type="important">While this approach is slightly better than editing default files in place, it can still
  51. cause problems when upgrading the toolkit to a new version. Since the <filepath>Customization</filepath> folder
  52. is located within the <filepath>org.dita.pdf2</filepath> plug-in’s parent directory, users must be take care to
  53. preserve the contents of this folder when upgrading to new toolkit versions.</note>
  54. <p>Although recent versions of DITA-OT still support this mechanism to ensure backwards compatibility, this
  55. practice is deprecated in favor of custom PDF plug-ins.</p>
  56. <note type="tip">Users who have used the <filepath>Customization</filepath> folder to modify the default PDF
  57. output are encouraged to create a custom PDF plug-in instead. In many cases, this may be as simple as copying
  58. the contents of the <filepath>Customization</filepath> folder to a new subfolder in the
  59. <filepath>plugins</filepath> folder and creating the necessary <filepath>plugin.xml</filepath> file and an Ant
  60. script to define the transformation type as described in the following example.</note>
  61. </section>
  62. <section id="external_customization_directories">
  63. <title>Specifying an external customization directory</title>
  64. <p>To ensure that overrides in customization folders are not overwritten when upgrading DITA-OT to a new release,
  65. an external customization directory can be specified at build time or in build scripts via the
  66. <parmname>customization.dir</parmname> parameter.</p>
  67. <p>This method is preferable to the use of the <filepath>org.dita.pdf2/Customization</filepath> folder, as the
  68. contents of external folders are unaffected when upgrading DITA-OT. In distributed environments, users can use
  69. local installations of DITA-OT, yet still take advantage of common customizations stored in a network location
  70. available to the entire team, such as a shared drive.</p>
  71. <p>It can also be useful in environments where corporate policy, CMS permissions, or network access rights prevent
  72. changes to the toolkit installation, which may prohibit the installation of custom plug-ins.</p>
  73. <note type="tip">Users who specify external customization directories via <parmname>customization.dir</parmname>
  74. are encouraged to create a custom PDF plug-in if possible.</note>
  75. </section>
  76. <section id="plug_ins_and_customization_folders">
  77. <title>Combining custom plug-ins &amp; customization directories</title>
  78. <p>A common custom plug-in may be used to store base overrides that are applicable to all company publications,
  79. and the <parmname>customization.dir</parmname> parameter can be passed at build time to override individual
  80. settings as necessary for a given project or publication.</p>
  81. <p>In this case, any settings in the customization directory will take precedence over their counterparts in the
  82. custom plug-in or default <filepath>org.dita.pdf2</filepath> plug-in.</p>
  83. <p>This approach allows a single custom plug-in to be shared between multiple publications or the entire company,
  84. without the need to create additional plug-in dependencies per project.</p>
  85. <p>However, the use of multiple customization mechanisms can make it difficult to debug the precedence cascade and
  86. determine the origin of local formatting or processing overrides.</p>
  87. <note type="tip">In most scenarios, the use of dedicated PDF customization plug-ins is preferable. Common
  88. customizations can be bundled in one plug-in, and any project-specific overrides can be maintained in separate
  89. plug-ins that build on the base branding or other settings in the common custom plug-in.</note>
  90. </section>
  91. </conbody>
  92. </concept>