euske/pdfminer — Issue #11: allow grep in xml output
Author: jnweiger
Created: 2011-12-20 18:23:59+00:00
State: open

The XML output often contains no text words, but has each character as an individual

C

elements.
This patch proposes to add the string of words as a text="..." attribute to the parent element, so that browsing, debugging, and using grep is better supported.

--- euske-pdfminer-c770904/pdfminer/converter.py.orig	2011-11-07 14:29:24.000000000 +0000
+++ euske-pdfminer-c770904/pdfminer/converter.py	2011-12-20 18:07:57.312326172 +0000
@@ -442,7 +442,11 @@ class XMLConverter(PDFConverter):
render(child)
self.outfp.write('

\n')
elif isinstance(item, LTTextLine):
- self.outfp.write('\n' % bbox2str(item.bbox))
+ child_str = ''
+ for child in item:
+ if isinstance(child, LTChar):
+ child_str += child.get_text()
+ self.outfp.write('\n' % (bbox2str(item.bbox),enc(child_str)))
for child in item:
render(child)
self.outfp.write('\n')