You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在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:

For Apache FOP

Apache FOP relies on a dedicated configuration file to define PDF viewer behavior. Here's exactly what you need to do:

  1. Locate the FOP config file
    Find fop.xconf in your DITA OT installation—usually at plugins/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.

  2. 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>
    
  3. Link your custom plugin to the modified config
    If you’re using a custom plugin, update its plugin.xml to reference your edited fop.xconf instead of the default one, so the transformation picks up your changes.

For Oxygen PDF Chemistry

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:

  1. 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>
    
  2. 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

火山引擎 最新活动