Attachment 'pdfFilter.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - pdffilter
4
5 Depends on : pypdf (library used to read in a .pdf file)
6
7 Extracts the content of a Pdf file
8
9 @copyright: 2007 by MoinMoin:ThomasCordival
10 @license: GNU GPL, see COPYING for details.
11 """
12
13 import sys
14 from pyPdf import PdfFileReader
15
16 def execute(indexobj, filename):
17 try:
18 input = PdfFileReader(file(filename, "rb"))
19 pageNbr = input.getNumPages()
20 data = []
21 for i in range(pageNbr - 1):
22 data.append(input.getPage(i).extractText())
23 except RuntimeError, err:
24 indexobj.request.log(str(err))
25 data = []
26 return u'\n'.join(data)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.