@@ -36,7 +36,7 @@ class PDFHandler:
36
36
37
37
"""
38
38
39
- def __init__ (self , filepath : Union [StrByteType , Path ], pages = "1" , password = None ):
39
+ def __init__ (self , filepath : Union [StrByteType , Path ], pages = "1" , password = None , multi = [] ):
40
40
if is_url (filepath ):
41
41
filepath = download_url (filepath )
42
42
self .filepath : Union [StrByteType , Path ] = filepath
@@ -51,6 +51,7 @@ def __init__(self, filepath: Union[StrByteType, Path], pages="1", password=None)
51
51
if sys .version_info [0 ] < 3 :
52
52
self .password = self .password .encode ("ascii" )
53
53
self .pages = self ._get_pages (pages )
54
+ self .multi = multi
54
55
55
56
def _get_pages (self , pages ):
56
57
"""Converts pages string to list of ints.
@@ -188,6 +189,15 @@ def parse(
188
189
with mp .get_context ("spawn" ).Pool (processes = cpu_count ) as pool :
189
190
jobs = []
190
191
for p in self .pages :
192
+ p_no = p
193
+
194
+ page_kwargs = kwargs
195
+ page_parser = parser
196
+
197
+ if p_no in self .multi :
198
+ page_kwargs .update (self .multi [p_no ])
199
+ page_parser = Lattice (** page_kwargs ) if flavor == 'lattice' else Stream (** page_kwargs )
200
+
191
201
j = pool .apply_async (
192
202
self ._parse_page ,(p , tempdir , parser , suppress_stdout , layout_kwargs )
193
203
)
@@ -198,6 +208,15 @@ def parse(
198
208
tables .extend (t )
199
209
else :
200
210
for p in self .pages :
211
+ p_no = p
212
+
213
+ page_kwargs = kwargs
214
+ page_parser = parser
215
+
216
+ if p_no in self .multi :
217
+ page_kwargs .update (self .multi [p_no ])
218
+ page_parser = Lattice (** page_kwargs ) if flavor == 'lattice' else Stream (** page_kwargs )
219
+
201
220
t = self ._parse_page (p , tempdir , parser , suppress_stdout , layout_kwargs )
202
221
tables .extend (t )
203
222
@@ -224,7 +243,7 @@ def _parse_page(
224
243
-------
225
244
tables : camelot.core.TableList
226
245
List of tables found in PDF.
227
-
246
+
228
247
"""
229
248
self ._save_page (self .filepath , page , tempdir )
230
249
page_path = os .path .join (tempdir , f"page-{ page } .pdf" )
0 commit comments