pdf-customization-approaches.dita 6.7 KB

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