pdf-customization-approaches.html 12 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html
  2. SYSTEM "about:legacy-compat">
  3. <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2019"><meta name="DC.rights.owner" content="(C) Copyright 2019"><meta name="DC.type" content="concept"><meta name="description" content="Various methods may be used to customize the PDF output that DITA Open Toolkit produces. Each of these approaches have advantages and shortcomings that should be considered when preparing a customization project. Some of these methods are considered “anti-patterns” with disadvantages that outweigh their apparent appeal. In most cases, you should create a custom PDF plug-in."><meta name="DC.subject" content="PDF, customizing, best practices, upgrading, default plug-ins"><meta name="keywords" content="PDF, customizing, best practices, upgrading, default plug-ins"><meta name="DC.relation" scheme="URI" content="../topics/pdf-customization.html"><meta name="DC.relation" scheme="URI" content="../topics/plugin-best-practices.html"><meta name="DC.relation" scheme="URI" content="../topics/plugin-coding-conventions.html"><meta name="DC.format" content="HTML5"><meta name="DC.identifier" content="pdf_customization_approaches"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>PDF customization approaches</title></head><body id="pdf_customization_approaches"><header role="banner"><div class="header">
  4. <p>DITA Open Toolkit</p>
  5. <hr>
  6. </div></header><nav role="toc"><ul><li><a href="../index.html">DITA Open Toolkit 3.3</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../topics/installing-client.html">Installing DITA-OT</a></li><li><a href="../topics/alternative-input-formats.html">Authoring formats</a></li><li><a href="../topics/building-output.html">Building output</a></li><li><a href="../parameters/index.html">Setting parameters</a></li><li><a href="../topics/customizing.html">Customizing DITA-OT</a><ul><li><a href="../topics/html-customization.html">Customizing HTML</a></li><li><a href="../topics/pdf-customization.html">Customizing PDF</a><ul><li class="active"><a href="../topics/pdf-customization-approaches.html">PDF customization approaches</a></li><li><a href="../topics/pdf-customization-plugin-types.html">Types of custom PDF plug-ins</a></li><li><a href="../topics/pdf-plugin-structure.html">PDF plug-in structure</a></li><li><a href="../topics/pdf-customization-example.html">Simple PDF plug-in example</a></li><li><a href="../topics/pdf-customization-resources.html">Custom PDF plug-in resources</a></li><li><a href="../topics/pdf2-creating-change-bars.html">Generating revision bars</a></li></ul></li><li><a href="../topics/custom-plugins.html">Working with plug-ins</a></li><li><a href="../extension-points/plugin-extension-points.html">Extension points</a></li><li><a href="../topics/migration.html">Migrating customizations</a></li><li><a href="../topics/globalization.html">Globalizing DITA content</a></li><li><a href="../topics/rebuilding-docs.html">Rebuilding documentation</a></li></ul></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a></li><li><a href="../topics/dita-and-dita-ot-resources.html">Resources</a></li></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1">
  7. <h1 class="title topictitle1" id="ariaid-title1">PDF customization approaches</h1>
  8. <div class="body conbody"><p class="shortdesc">Various methods may be used to customize the PDF output that DITA Open Toolkit produces. Each of these
  9. approaches have advantages and shortcomings that should be considered when preparing a customization project. Some
  10. of these methods are considered “anti-patterns” with disadvantages that outweigh their apparent appeal. In most
  11. cases, you should create a custom PDF plug-in.</p>
  12. <section class="section" id="pdf_customization_approaches__why_not_edit_default_files"><h2 class="title sectiontitle">Why not edit default files?</h2>
  13. <p class="p">When first experimenting with PDF customization, novice users are often tempted to simply edit the default
  14. <span class="ph filepath">org.dita.pdf2</span> files in place to see what happens.</p>
  15. <p class="p">As practical as this approach may seem, the DITA-OT project does not recommend changing any of the files in the
  16. default plug-ins.</p>
  17. <p class="p">While this method yields quick results and can help users to determine which files and templates control
  18. various aspects of PDF output, it quickly leads to problems, as any errors may prevent the toolkit from
  19. generating PDF output.</p>
  20. <div class="note warning note_warning"><span class="note__title">Warning:</span> Any changes made in this fashion would be overwritten when upgrading to newer versions of
  21. DITA-OT, so users that have customized their toolkit installation in this way are often “stuck” on older
  22. versions of the toolkit and unable to take advantage of improvements in recent versions of DITA-OT.</div>
  23. </section>
  24. <section class="section" id="pdf_customization_approaches__the_customization_folder"><h2 class="title sectiontitle">Using the <span class="ph filepath">Customization</span> folder</h2>
  25. <div class="div div-index">
  26. </div>
  27. <p class="p">The original Idiom plug-in used its own extension mechanism to provide overrides to the PDF transformation.
  28. With this approach, a dedicated folder within the plug-in is used to store customized files.</p>
  29. <p class="p">Files in the <span class="ph filepath">org.dita.pdf2/Customization</span> folder can override their default counterparts,
  30. allowing users to adjust certain aspects of PDF output without changing any of the plug-in’s default files, or
  31. specifying additional parameters when generating output.</p>
  32. <div class="note important note_important"><span class="note__title">Important:</span> While this approach is slightly better than editing default files in place, it can still
  33. cause problems when upgrading the toolkit to a new version. Since the <span class="ph filepath">Customization</span> folder
  34. is located within the <span class="ph filepath">org.dita.pdf2</span> plug-in’s parent directory, users must be take care to
  35. preserve the contents of this folder when upgrading to new toolkit versions.</div>
  36. <p class="p">Although recent versions of DITA-OT still support this mechanism to ensure backwards compatibility, this
  37. practice is deprecated in favor of custom PDF plug-ins.</p>
  38. <div class="note tip note_tip"><span class="note__title">Tip:</span> Users who have used the <span class="ph filepath">Customization</span> folder to modify the default PDF
  39. output are encouraged to create a custom PDF plug-in instead. In many cases, this may be as simple as copying
  40. the contents of the <span class="ph filepath">Customization</span> folder to a new subfolder in the
  41. <span class="ph filepath">plugins</span> folder and creating the necessary <span class="ph filepath">plugin.xml</span> file and an Ant
  42. script to define the transformation type as described in the following example.</div>
  43. </section>
  44. <section class="section" id="pdf_customization_approaches__external_customization_directories"><h2 class="title sectiontitle">Specifying an external customization directory</h2>
  45. <p class="p">To ensure that overrides in customization folders are not overwritten when upgrading DITA-OT to a new
  46. release, an external customization directory can be specified at build time or in build scripts via the
  47. <span class="keyword parmname">customization.dir</span> parameter.</p>
  48. <p class="p">This method is preferable to the use of the <span class="ph filepath">org.dita.pdf2/Customization</span> folder, as the
  49. contents of external folders are unaffected when upgrading DITA-OT. In distributed environments, users can use
  50. local installations of DITA-OT, yet still take advantage of common customizations stored in a network location
  51. available to the entire team, such as a shared drive.</p>
  52. <p class="p">It can also be useful in environments where corporate policy, CMS permissions, or network access rights prevent
  53. changes to the toolkit installation, which may prohibit the installation of custom plug-ins.</p>
  54. <div class="note tip note_tip"><span class="note__title">Tip:</span> Users who specify external customization directories via <span class="keyword parmname">customization.dir</span>
  55. are encouraged to create a custom PDF plug-in if possible.</div>
  56. </section>
  57. <section class="section" id="pdf_customization_approaches__plug_ins_and_customization_folders"><h2 class="title sectiontitle">Combining custom plug-ins &amp; customization directories</h2>
  58. <p class="p">A common custom plug-in may be used to store base overrides that are applicable to all company publications,
  59. and the <span class="keyword parmname">customization.dir</span> parameter can be passed at build time to override individual
  60. settings as necessary for a given project or publication.</p>
  61. <p class="p">In this case, any settings in the customization directory will take precedence over their counterparts in the
  62. custom plug-in or default <span class="ph filepath">org.dita.pdf2</span> plug-in.</p>
  63. <p class="p">This approach allows a single custom plug-in to be shared between multiple publications or the entire company,
  64. without the need to create additional plug-in dependencies per project.</p>
  65. <p class="p">However, the use of multiple customization mechanisms can make it difficult to debug the precedence cascade and
  66. determine the origin of local formatting or processing overrides.</p>
  67. <div class="note tip note_tip"><span class="note__title">Tip:</span> In most scenarios, the use of dedicated PDF customization plug-ins is preferable. Common
  68. customizations can be bundled in one plug-in, and any project-specific overrides can be maintained in separate
  69. plug-ins that build on the base branding or other settings in the common custom plug-in.</div>
  70. </section>
  71. </div>
  72. <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/pdf-customization.html" title="You can create custom DITA-OT plug-ins that build on the default DITA to PDF transformation. Plug-ins can customize covers and page layouts, modify formatting, override logic of the default PDF plug-in, and much more.">Customizing PDF output</a></div></div><div class="linklist relinfo relconcepts"><strong>Related concepts</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="../topics/plugin-best-practices.html" title="Adhering to certain development practices will properly isolate your code from that of DITA Open Toolkit. This will make it easier to you to upgrade to new versions of DITA-OT when they are released.">Best practices for custom plug-ins</a></li><li class="linklist"><a class="link" href="../topics/plugin-coding-conventions.html" title="To ensure custom plug-ins work well with the core toolkit code and remain compatible with future releases, the DITA Open Toolkit project recommends that plug-ins use modern development practices and common coding patterns.">Plug-in coding conventions</a></li></ul></div></nav></article></main></body></html>