Popular recipes tagged "ebooks" and "elementtree" but not "reportlab"http://code.activestate.com/recipes/tags/ebooks-reportlab+elementtree/2013-06-16T19:14:58-07:00ActiveState Code RecipesXML to PDF book with ElementTree and xtopdf (Python)
2013-06-16T19:14:58-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578561-xml-to-pdf-book-with-elementtree-and-xtopdf/
<p style="color: grey">
Python
recipe 578561
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/ebooks/">ebooks</a>, <a href="/recipes/tags/elementtree/">elementtree</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/publishing/">publishing</a>, <a href="/recipes/tags/xml/">xml</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>).
</p>
<p>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.</p>
<p>Create an XML template file like this:</p>
<p><?xml version="1.0"?>
<book>
<chapter>
Chapter 1 content here.
</chapter></p>
<pre class="prettyprint"><code> <chapter>
Chapter 2 content here.
</chapter>
</code></pre>
<p></book></p>
<p>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.</p>
<p>Then run:</p>
<p>python XMLtoPDFBook.py your_book.xml your_book.pdf</p>
<p>Now the contents of your book will be in your_book.pdf</p>
<p>More details and the full code here:</p>
<p><a href="http://jugad2.blogspot.in/2013/06/create-pdf-books-with-xmltopdfbook.html" rel="nofollow">http://jugad2.blogspot.in/2013/06/create-pdf-books-with-xmltopdfbook.html</a></p>
<ul>
<li>Vasudev Ram
<a href="http://dancingbison.com" rel="nofollow">dancingbison.com</a></li>
</ul>