如何在DITA输出中配置PDF初始视图设置
Alright, let's tackle how to set those PDF initial view parameters when using DITA OT with either Apache FOP or Oxygen PDF Chemistry. Both engines require modifying specific plugin files, so I'll break this down for each one:
Apache FOP relies on a dedicated configuration file to define PDF viewer behavior. Here's exactly what you need to do:
Locate the FOP config file
Findfop.xconfin your DITA OT installation—usually atplugins/org.dita.pdf2/fop/fop.xconf. If you’re using a custom PDF plugin, copy this file to your plugin’s directory to override the default settings safely.Add the initial view settings
Inside the<renderers>section, find the<renderer mime="application/pdf">block, then insert a<pdf-viewer-settings>element with your desired parameters:<renderer mime="application/pdf"> <!-- Your existing FOP configuration goes here --> <pdf-viewer-settings> <navigation-pane state="open"/> <page-layout>single-page-continuous</page-layout> <zoom type="fit-page"/> <open-page-number>1</open-page-number> <window> <fit-window>true</fit-window> <show-document-title>true</show-document-title> </window> </pdf-viewer-settings> </renderer>Link your custom plugin to the modified config
If you’re using a custom plugin, update itsplugin.xmlto reference your editedfop.xconfinstead of the default one, so the transformation picks up your changes.
Oxygen PDF Chemistry uses CSS properties or plugin parameters to control PDF initial view. You have two straightforward options:
Option 1: Use custom CSS
Add these properties to your plugin’s custom CSS file (typically part of your DITA OT PDF customization):
@page { -oxy-pdf-initial-view: "bookmarks=open&layout=singlePageContinuous&zoom=fitPage&page=1"; -oxy-pdf-window-options: "fitWindow=true&displayTitle=true"; }
Option 2: Modify the plugin’s configuration
If you prefer setting parameters directly in the plugin:
- Edit the plugin’s
plugin.xml
Locate the<transtype name="pdf-css-html5">section, then add the required parameters:<transtype name="pdf-css-html5"> <!-- Existing plugin configuration --> <param name="oxy-pdf-initial-view" value="bookmarks=open&layout=singlePageContinuous&zoom=fitPage&page=1"/> <param name="oxy-pdf-window-options" value="fitWindow=true&displayTitle=true"/> </transtype> - Or pass parameters via command line
If you don’t want to modify the plugin permanently, include these parameters when running your transformation:dita -i input.ditamap -f pdf-css-html5 -Doxy-pdf-initial-view="bookmarks=open&layout=singlePageContinuous&zoom=fitPage&page=1" -Doxy-pdf-window-options="fitWindow=true&displayTitle=true"
Quick Tips
- For custom plugins, ensure you’re overriding default settings correctly (either by extending the base PDF plugin or replacing relevant files).
- After making changes, rebuild your plugin if needed and test the PDF output to confirm the initial view matches your requirements.
内容的提问来源于stack exchange,提问作者Antony




