本文介绍了如何从docbook 5.0生成pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个docbook 5.0文档,其标题为:

I've written a docbook 5.0 document with the header:

<?xml version="1.0" encoding="UTF-8"?>
<book version="5.0" xmlns="http://docbook.org/ns/docbook"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:svg="http://www.w3.org/2000/svg"
      xmlns:m="http://www.w3.org/1998/Math/MathML"
      xmlns:html="http://www.w3.org/1999/xhtml"
      xmlns:db="http://docbook.org/ns/docbook">

和Ubuntu 9.10上的docbook2pdf会打印许多错误消息,并且不执行任何pdf文档.错误是:

and docbook2pdf on Ubuntu 9.10 prints many error messages and doesn't do any pdf document. The errors are:

openjade:test.xml:2:0:E: prolog can't be omitted unless CONCUR NO and LINK EXPLICIT NO and either IMPLYDEF ELEMENT YES or IMPLYDEF DOCTYPE YES
openjade:test.xml:2:0:E: no document type declaration; will parse without validation
openjade:/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/dbtitle.dsl:18:5:E: flow objects at the root must be all of class scroll or all of class page-sequence or simple-page-sequence
openjade:/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/dbbibl.dsl:704:4:E: flow objects at the root must be all of class scroll or all of class page-sequence or simple-page-sequence

docbook2pdf,用于docbook 4.5格式的文档,其标头如下:

docbook2pdf for document in the docbook 4.5 format with normal header like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

工作正常.

有什么方法可以从docbook 5.0生成pdf吗?

Is there any way to generate pdf from docbook 5.0?

推荐答案

我看到了三个从docbook生成pdf的选项(在Debian/Ubuntu中可用):

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

  • jade,它提供了asker使用的docbook2pdf命令.玉是古老的,可以与SGML一起使用,SGML早于XML,不支持Unicode.它还缺乏对docbook 5的支持.

  • 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.

docbook-xsl 样式表. docbook-xsl适用于docbook 4.5,docbook-xsl-ns适用于docbook5.使用fop从XSL-FO转换为PDF.管道:docbook5-(xsl)-> xml.fo-(fop)-> pdf.涉及的命令:xsltproc,fop.

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,主要针对docbook4.5,但已针对某些docbook5进行了更新.

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

xmlto可以驱动最后两个,尽管当前默认为docbook-xsl而不是docbook-xsl-ns.

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

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

验证

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

PDF输出

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

这篇关于如何从docbook 5.0生成pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 07:57