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.
  • [get | view] (2007-12-03 22:39:02, 0.6 KB) [[attachment:application_pdf.py]]
  • [get | view] (2007-12-03 22:43:36, 2.1 KB) [[attachment:application_vnd_ms_excel.py]]
  • [get | view] (2007-12-03 22:35:35, 2.1 KB) [[attachment:excelFilter.py]]
  • [get | view] (2007-12-03 22:35:41, 0.6 KB) [[attachment:pdfFilter.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.