Created
June 7, 2014 20:02
-
-
Save victoraguilarc/e289972a9bc7d8b65110 to your computer and use it in GitHub Desktop.
test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- encoding:utf8 -*- | |
| import pdfquery | |
| pdf = pdfquery.PDFQuery("mipdf.pdf") | |
| pdf.load() | |
| gobierno = pdf.pq('LTTextLineHorizontal:contains("Gobierno Aut")')[0] | |
| # print gobierno.length | |
| programa = pdf.pq('LTTextLineHorizontal:contains("PROGRAMA")')[0] | |
| proyecto = pdf.pq('LTTextLineHorizontal:contains("PROYECTO")')[0] | |
| programa_x0 = programa.layout.x0 + 150 | |
| programa_height = programa.layout.height | |
| programa_y0 = programa.layout.y0 | |
| proyecto_x0 = proyecto.layout.x0 + 300 | |
| proyecto_height = proyecto.layout.height | |
| proyecto_y0 = proyecto.layout.y0 | |
| programa_content = pdf.pq('LTTextLineHorizontal:in_bbox("%s, %s, %s, %s")' % (programa_x0, programa_y0, programa_x0+800, programa_y0 + programa_height)).text() | |
| proyecto_content = pdf.pq('LTTextLineHorizontal:in_bbox("%s, %s, %s, %s")' % (proyecto_x0, proyecto_y0, proyecto_x0+800, proyecto_y0 + proyecto_height)).text() | |
| print programa_content | |
| print proyecto_conte |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment