aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Delaney <della5@iinet.com.au>2012-06-04 17:23:35 +0800
committerIan Delaney <della5@iinet.com.au>2012-06-04 17:23:35 +0800
commitbdb3ea78f0c73f3f635d858a6a4720c95427439d (patch)
treed33bc7f12645045ab2d544d0f63a2d9785f5dd2f
parent[dev-python/bunch] Add new ebuild (diff)
downloadimprovise-bdb3ea78f0c73f3f635d858a6a4720c95427439d.tar.gz
improvise-bdb3ea78f0c73f3f635d858a6a4720c95427439d.tar.bz2
improvise-bdb3ea78f0c73f3f635d858a6a4720c95427439d.zip
[dev-python/cookbook] Add HTML2PDF and matching epatch line
(Portage version: 2.1.10.63/git/Linux x86_64, unsigned Manifest commit)
-rw-r--r--dev-python/cookbook/cookbook-2.2.9.ebuild4
-rw-r--r--dev-python/cookbook/files/HTML2PDF52
2 files changed, 56 insertions, 0 deletions
diff --git a/dev-python/cookbook/cookbook-2.2.9.ebuild b/dev-python/cookbook/cookbook-2.2.9.ebuild
index cfe7551..1f7b6f9 100644
--- a/dev-python/cookbook/cookbook-2.2.9.ebuild
+++ b/dev-python/cookbook/cookbook-2.2.9.ebuild
@@ -25,6 +25,10 @@ DEPEND="${RDEPEND}
dev-python/pytables
sci-libs/scipy )"
+src_prepare() {
+ cp -R "${FILESDIR}"/HTML2PDF python/${PN}/HTML2PDF.py || die
+}
+
src_compile() {
distutils_src_compile
diff --git a/dev-python/cookbook/files/HTML2PDF b/dev-python/cookbook/files/HTML2PDF
new file mode 100644
index 0000000..449cbed
--- /dev/null
+++ b/dev-python/cookbook/files/HTML2PDF
@@ -0,0 +1,52 @@
+## {{{ http://code.activestate.com/recipes/572160/ (r1)
+import cStringIO
+import ho.pisa as pisa
+import os
+
+# Shortcut for dumping all logs on screen
+pisa.showLogging()
+
+def HTML2PDF(data, filename, open=False):
+
+ """
+ Simple test showing how to create a PDF file from
+ PML Source String. Also shows errors and tries to start
+ the resulting PDF
+ """
+
+ pdf = pisa.CreatePDF(
+ cStringIO.StringIO(data),
+ file(filename, "wb"))
+
+ if open and (not pdf.err):
+ os.startfile(str(filename))
+
+ return not pdf.err
+
+if __name__=="__main__":
+ HTMLTEST = """
+ <html><body>
+ <p>Hello <strong style="color: #f00;">World</strong>
+ <hr>
+ <table border="1" style="background: #eee; padding: 0.5em;">
+ <tr>
+ <td>Amount</td>
+ <td>Description</td>
+ <td>Total</td>
+ </tr>
+ <tr>
+ <td>1</td>
+ <td>Good weather</td>
+ <td>0 EUR</td>
+ </tr>
+ <tr style="font-weight: bold">
+ <td colspan="2" align="right">Sum</td>
+ <td>0 EUR</td>
+ </tr>
+ </table>
+ </body></html>
+ """
+
+ HTML2PDF(HTMLTEST, "test.pdf", open=True)
+## end of http://code.activestate.com/recipes/572160/ }}}
+