How to generate pdf from docbook 5.0

↘锁芯ラ 提交于 2019-12-02 17:46:53

I see three options (available in Debian/Ubuntu) to generate pdf from docbook:

  • jade, which provides the docbook2pdf command the asker used. jade is ancient and works with SGML, which predates XML and does not support Unicode; it also lacks support for docbook 5.

  • the docbook-xsl stylesheets which go through XSL-FO. docbook-xsl is for docbook 4.5, docbook-xsl-ns is for docbook5. Use fop to go from XSL-FO to PDF. Pipeline: docbook5 —(xsl)—> xml.fo —(fop)—> pdf . Commands involved: xsltproc, fop.

  • dblatex, which is primarily targeting docbook4.5 but has been updated for some of docbook5.

xmlto can drive the last two, although it currently defaults to docbook-xsl and not docbook-xsl-ns.


A quick Docbook5 user guide

Prerequisites

sudo aptitude install docbook5 docbook-xsl-ns xsltproc fop xmlto libxml2-utils xmlstarlet

Validation

xmlstarlet val --err --xsd /usr/share/xml/docbook/schema/xsd/5.0/docbook.xsd book.xml

PDF output

xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl-ns/fo/docbook.xsl book.xml > book.fo
fop -fo book.fo -pdf book.pdf

Apart from the header you gave, did you try a smaller example, like this one from the DocBook 5.0: The Definitive Guide ?

<?xml version="1.0" encoding="UTF-8"?>

<book xmlns='http://docbook.org/ns/docbook'>
  <title>An Example Book</title>
  <titleabbrev>Example</titleabbrev>
  <info>
    <legalnotice><para>No notice is required.</para></legalnotice>
    <author><personname>
      <firstname>Norman</firstname><surname>Walsh</surname>
    </personname></author>
  </info>

  <dedication>
  <para>
      This book is dedicated to you.
  </para>
  </dedication>

  <preface>
    <title>Foreword</title>
    <para>
        Some content is always required.
    </para>
  </preface>

  <chapter>
    <title>A Chapter</title>
    <para>
        Content is required in chapters too.
    </para>
  </chapter>

  <appendix>
    <title>Optional Appendix</title>
    <para>
        Appendixes are optional.
    </para>
  </appendix>
</book>

Just rendered it to a PDF through one of my Maven environments. Can you give a small example (or a few separated onces) containing some content, which makes the use of all the additional name spaces necessary.

In case the above example does not work, and you are interested in how I have setup my environment read Making DocBook content available in a Maven project site. Just replace the example with the above DocBook 5.0 example. Only the docbkx-maven-plugin is of interest, in relation to this question. (PS: Some basic knowledge of Java and Maven2 is required for this.)

ddri

Publican

You can use Publican to publish your DocBook XML in PDF, html, and html-single formats. Publican is used by Red Hat as part of its internal documentation toolchain, and is an open source application hosted by the Fedora project. The tool uses "brands" to achieve a modularity in applying styles to the content being published. This preset manner simusing a wide variety of CMS or documentation tools.

JBoss Documentation Guide

A good example of the tool in action is the JBoss Press Gang documentation, which is itself a great resource the gives documentation community guidance on the use of DocBook XML in JBoss documentation. The html and PDF versions were generated with Publican.

Hicham Bakir

There are significant differences between Docbook 4.5 and 5.0. And those differences can prevent your document from being transformed.

If you want to check the validity of your 5.0 document, you can use the following command line tool:

  1. it's a java tool, so you need to have a recent java runtime environment.

  2. the tool is Jing. You can download it from thaiopensource web site: http://www.thaiopensource.com/relaxng/jing.html

  3. you will also need the relax ng file for docbook 5.0. It is provided with the docbook 5 distribution.

  4. run the validation test with the following command line:
    java -jar path_to_Jing/jing.jar -t -i path_to_docbook5/docbook.rng document.xml

If there are some failures, they should be returned this way: Error at URL "file:...../document.xml", line number 211, column number 59: bad value for attribute "id" from namespace "http://www.w3.org/XML/1998/namespace" Elapsed time 968+166=1134 milliseconds

http://docbookpublishing.com supports DocBook 5.0 documents. It is an online service for DocBook to PDF formatting. You can also submit your DocBook documents via the REST API.

Gangnus

Go to Eclipse and install DocBook Editing and Processing for Eclipse (DEP4E) plugin. You can find it by going into marketplace and search for docbook there. This plugin will create an example docbook and can publish in html, pdf, and even ebook.

Or check out the DEP4E web site, read the Quick Starter Guide section 3. Getting Started, to get an idea of it's possibilities.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!