@@ -36,7 +36,7 @@ class PDFHandler:
3636
3737 """
3838
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 = [] ):
4040 if is_url (filepath ):
4141 filepath = download_url (filepath )
4242 self .filepath : Union [StrByteType , Path ] = filepath
@@ -51,6 +51,7 @@ def __init__(self, filepath: Union[StrByteType, Path], pages="1", password=None)
5151 if sys .version_info [0 ] < 3 :
5252 self .password = self .password .encode ("ascii" )
5353 self .pages = self ._get_pages (pages )
54+ self .multi = multi
5455
5556 def _get_pages (self , pages ):
5657 """Converts pages string to list of ints.
@@ -188,6 +189,15 @@ def parse(
188189 with mp .get_context ("spawn" ).Pool (processes = cpu_count ) as pool :
189190 jobs = []
190191 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+
191201 j = pool .apply_async (
192202 self ._parse_page ,(p , tempdir , parser , suppress_stdout , layout_kwargs )
193203 )
@@ -198,6 +208,15 @@ def parse(
198208 tables .extend (t )
199209 else :
200210 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+
201220 t = self ._parse_page (p , tempdir , parser , suppress_stdout , layout_kwargs )
202221 tables .extend (t )
203222
@@ -224,7 +243,7 @@ def _parse_page(
224243 -------
225244 tables : camelot.core.TableList
226245 List of tables found in PDF.
227-
246+
228247 """
229248 self ._save_page (self .filepath , page , tempdir )
230249 page_path = os .path .join (tempdir , f"page-{ page } .pdf" )
0 commit comments