This recipe shows how to create a PDF book from XML text content. It requires my xtopdf toolkit, the ElementTree module (from Python's standard library) and the open source version of the ReportLab toolkit.
Create an XML template file like this:
<?xml version="1.0"?> <book> <chapter> Chapter 1 content here. </chapter>
<chapter> Chapter 2 content here. </chapter>
Then populate the chapter elements with the text of each of the chapters of your book, as text. Call that file, your_book.xml, say.
python XMLtoPDFBook.py your_book.xml your_book.pdf
Now the contents of your book will be in your_book.pdf
More details and the full code here:
- Vasudev Ram dancingbison.com
Creating PDF books from XML text content.
This recipe provides an easy and quick way to create simple PDF ebooks from text content stored in an XML file.
It is like a much simpler version of DocBook. DocBook is much more powerful and has many more features, but also requires more setup and a more complicated toolchain to produce the PDF.