Fixes needed to be able to compile pdfminer.six with Cython
parent
eddf861fbd
commit
4bdb3ba8cc
|
@ -15,6 +15,8 @@ import array
|
||||||
|
|
||||||
import six #Python 2+3 compatibility
|
import six #Python 2+3 compatibility
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
def get_bytes(data):
|
def get_bytes(data):
|
||||||
for byte in data:
|
for byte in data:
|
||||||
|
@ -598,7 +600,7 @@ def main(argv):
|
||||||
pygame.image.save(self.img, 'out.bmp')
|
pygame.image.save(self.img, 'out.bmp')
|
||||||
return
|
return
|
||||||
for path in argv[1:]:
|
for path in argv[1:]:
|
||||||
fp = file(path, 'rb')
|
fp = open(path, 'rb')
|
||||||
(_, _, k, w, h, _) = path.split('.')
|
(_, _, k, w, h, _) = path.split('.')
|
||||||
parser = Parser(int(w))
|
parser = Parser(int(w))
|
||||||
parser.feedbytes(fp.read())
|
parser.feedbytes(fp.read())
|
||||||
|
|
|
@ -426,7 +426,7 @@ class CMapParser(PSStackParser):
|
||||||
def main(argv):
|
def main(argv):
|
||||||
args = argv[1:]
|
args = argv[1:]
|
||||||
for fname in args:
|
for fname in args:
|
||||||
fp = file(fname, 'rb')
|
fp = open(fname, 'rb')
|
||||||
cmap = FileUnicodeMap()
|
cmap = FileUnicodeMap()
|
||||||
#cmap = FileCMap()
|
#cmap = FileCMap()
|
||||||
CMapParser(cmap, fp).run()
|
CMapParser(cmap, fp).run()
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -3,7 +3,7 @@ import sys
|
||||||
|
|
||||||
import pdfminer as package
|
import pdfminer as package
|
||||||
|
|
||||||
requires = ['six', 'pycryptodome']
|
requires = ['six', 'pycryptodome', 'pygame']
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
requires.append('chardet')
|
requires.append('chardet')
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ def convert(infp, outfp, path, codec='utf-8',
|
||||||
maxpages=0, maxfilesize=0, pagenos=None,
|
maxpages=0, maxfilesize=0, pagenos=None,
|
||||||
html=True):
|
html=True):
|
||||||
# save the input file.
|
# save the input file.
|
||||||
src = file(path, 'wb')
|
src = open(path, 'wb')
|
||||||
nbytes = 0
|
nbytes = 0
|
||||||
while 1:
|
while 1:
|
||||||
data = infp.read(4096)
|
data = infp.read(4096)
|
||||||
|
@ -68,7 +68,7 @@ def convert(infp, outfp, path, codec='utf-8',
|
||||||
layoutmode='exact')
|
layoutmode='exact')
|
||||||
else:
|
else:
|
||||||
device = TextConverter(rsrcmgr, outfp, codec=codec, laparams=laparams)
|
device = TextConverter(rsrcmgr, outfp, codec=codec, laparams=laparams)
|
||||||
fp = file(path, 'rb')
|
fp = open(path, 'rb')
|
||||||
interpreter = PDFPageInterpreter(rsrcmgr, device)
|
interpreter = PDFPageInterpreter(rsrcmgr, device)
|
||||||
for page in PDFPage.get_pages(fp, pagenos, maxpages=maxpages):
|
for page in PDFPage.get_pages(fp, pagenos, maxpages=maxpages):
|
||||||
interpreter.process_page(page)
|
interpreter.process_page(page)
|
||||||
|
|
Loading…
Reference in New Issue