Add Stream benchmarks

This commit is contained in:
Vinayak Mehta
2018-09-12 07:21:35 +05:30
parent b276909a4f
commit 0ba3469d21
89 changed files with 848 additions and 34 deletions
+4
View File
@@ -81,6 +81,8 @@ class PDFHandler(object):
"""
with open(filename, 'rb') as fileobj:
infile = PdfFileReader(fileobj, strict=False)
if infile.isEncrypted:
infile.decrypt('')
fpath = os.path.join(temp, 'page-{0}.pdf'.format(page))
froot, fext = os.path.splitext(fpath)
p = infile.getPage(page - 1)
@@ -98,6 +100,8 @@ class PDFHandler(object):
fpath_new = ''.join([froot.replace('page', 'p'), '_rotated', fext])
os.rename(fpath, fpath_new)
infile = PdfFileReader(open(fpath_new, 'rb'), strict=False)
if infile.isEncrypted:
infile.decrypt('')
outfile = PdfFileWriter()
p = infile.getPage(0)
if rotation == 'anticlockwise':
+1 -2
View File
@@ -294,8 +294,7 @@ class Stream(BaseParser):
if ncols == 1:
logger.info("No tables found on {}".format(
os.path.basename(self.rootname)))
cols = [(t.x0, t.x1)
for r in rows_grouped if len(r) == ncols for t in r]
cols = [(t.x0, t.x1) for r in rows_grouped if len(r) == ncols for t in r]
cols = self._merge_columns(sorted(cols), col_close_tol=self.col_close_tol)
inner_text = []
for i in range(1, len(cols)):