Getting started with PDF Plugins

12 views
Skip to first unread message

Adam Retter

unread,
Aug 3, 2021, 12:07:37 PMAug 3
to DITA-OT Users
I am using DITA-OT 3.6.1, and I am trying to create a DITA-OT plugin to customise PDF production. I understand that plugins are now the preferred approach.

Ultimately I want two plugins, one for setting basic properties, e.g. Page Size, some formatting options, etc, and then another which may need to override some XSL:FO to do some custom formatting.

To get started, I am trying to very simply to create a PDF plugin  that just sets args.chapter.layout to BASIC.

I am following the example from the docs here - https://www.dita-ot.org/3.6/topics/plugin-set-parameters.html

I have read the DITA-OT docs a few times, but somehow I haven't found a good example with details of actually how to use it in practice.

My plugin.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://www.dita-ot.org/rng/plugin.rnc" type="application/relax-ng-compact-syntax"?>
<plugin id="uk.gov.nationalarchives.omega.dita-ot.pdf-settings">
  <require plugin="org.dita.pdf2"/>
  <transtype name="print-pdf" extends="pdf" desc="PDF on A4 paper"/>
  <feature extension="dita.transtype.print" value="print-pdf"/>
  <feature extension="ant.import" file="integrator.xml"/>
</plugin>

My integrator.xml looks like:

<?xml version='1.0' encoding='UTF-8'?>
<project name="uk.gov.nationalarchives.omega.dita-ot.pdf-settings">
  <target name="dita2draft.pdf.init">
    <!-- Disable the subsection links on the first page of each chapter -->
    <property name="args.chapter.layout" value="BASIC"/>
  </target>
  <target name="dita2draft.pdf" depends="dita2draft.pdf.init, dita2pdf2"/>
</project>


I have placed plugin.xml and integrator.xml into a Zip file and installed them into DITA-OT using:

dita install file:/tmp/uk.gov.nationalarchives.omega.dita-ot.pdf-settings.zip

I see it when I run `dita plugins`:
❯ dita plugins
org.dita.base
org.dita.eclipsehelp
org.dita.html5
org.dita.htmlhelp
org.dita.index
org.dita.normalize
org.dita.pdf2
org.dita.pdf2.axf
org.dita.pdf2.fop
org.dita.pdf2.xep
org.dita.specialization.dita11
org.dita.xhtml
org.lwdita
org.oasis-open.dita.techcomm.v2_0
org.oasis-open.dita.v1_2
org.oasis-open.dita.v1_3
org.oasis-open.dita.v2_0
org.oasis-open.xdita.v0_2_2
uk.gov.nationalarchives.omega.dita-ot.pdf-settings

If I run:
dita --verbose --input=/tmp/ocdm.ditamap --format=pdf --output=/tmp/out

I do get a PDF, but my plugin doesn't appear to have done anything at all.

If I try instead running:

dita --verbose --input=/tmp/ocdm.ditamap --format=print-pdf --output=/tmp/out

I get the errors:
Searching for integrator.xml ...

init:
Error: The following error occurred while executing this line:
Target "dita2print-pdf" does not exist in the project "DOST".

To be honest I am not really sure what I am meant to do, am I meant to define `dita2print-pdf` somewhere and if so, why, and what do I need to put there?

Any help on getting started (in-practice) would be appreciated...

Thanks Adam.

Radu Coravu

unread,
Aug 4, 2021, 12:38:56 AMAug 4
to Adam Retter, DITA-OT Users
Welcome Adam,

Maybe you can try Jarno Elovirta's PDF plugin generator page to generate valid DITA OT PDF customization plugins:

About what you did, you defined a new transformation type named "print-pdf" so indeed you should refer to it "--format=print-pdf " in the command line when building the PDF.
And inside your build file rename the target "dita2draft.pdf" to "dita2print-pdf", basically once you give in the command line the " --format=print-pdf", the DITA OT prefixes it with "dita2" and calls the ANT target with the name "dita2print-pdf" which gets to be defined by you.

Regards,
Radu

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/429a46cb-446a-4236-bb6c-a9c422871143n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages