@@ -528,6 +528,8 @@ def pdfinfo_from_path(
528
528
poppler_path : str = None ,
529
529
rawdates : bool = False ,
530
530
timeout : int = None ,
531
+ first_page : int = None ,
532
+ last_page : int = None ,
531
533
) -> Dict :
532
534
"""Function wrapping poppler's pdfinfo utility and returns the result as a dictionary.
533
535
@@ -543,6 +545,10 @@ def pdfinfo_from_path(
543
545
:type rawdates: bool, optional
544
546
:param timeout: Raise PDFPopplerTimeoutError after the given time, defaults to None
545
547
:type timeout: int, optional
548
+ :param first_page: First page to process, defaults to None
549
+ :type first_page: int, optional
550
+ :param last_page: Last page to process before stopping, defaults to None
551
+ :type last_page: int, optional
546
552
:raises PDFPopplerTimeoutError: Raised after the timeout for the image processing is exceeded
547
553
:raises PDFInfoNotInstalledError: Raised if pdfinfo is not installed
548
554
:raises PDFPageCountError: Raised if the output could not be parsed
@@ -561,6 +567,12 @@ def pdfinfo_from_path(
561
567
if rawdates :
562
568
command .extend (["-rawdates" ])
563
569
570
+ if first_page :
571
+ command .extend (["-f" , str (first_page )])
572
+
573
+ if last_page :
574
+ command .extend (["-l" , str (last_page )])
575
+
564
576
# Add poppler path to LD_LIBRARY_PATH
565
577
env = os .environ .copy ()
566
578
if poppler_path is not None :
@@ -607,6 +619,8 @@ def pdfinfo_from_bytes(
607
619
poppler_path : str = None ,
608
620
rawdates : bool = False ,
609
621
timeout : int = None ,
622
+ first_page : int = None ,
623
+ last_page : int = None ,
610
624
) -> Dict :
611
625
"""Function wrapping poppler's pdfinfo utility and returns the result as a dictionary.
612
626
@@ -622,6 +636,10 @@ def pdfinfo_from_bytes(
622
636
:type rawdates: bool, optional
623
637
:param timeout: Raise PDFPopplerTimeoutError after the given time, defaults to None
624
638
:type timeout: int, optional
639
+ :param first_page: First page to process, defaults to None
640
+ :type first_page: int, optional
641
+ :param last_page: Last page to process before stopping, defaults to None
642
+ :type last_page: int, optional
625
643
:return: Dictionary containing various information on the PDF
626
644
:rtype: Dict
627
645
"""
@@ -637,6 +655,8 @@ def pdfinfo_from_bytes(
637
655
poppler_path = poppler_path ,
638
656
rawdates = rawdates ,
639
657
timeout = timeout ,
658
+ first_page = first_page ,
659
+ last_page = last_page ,
640
660
)
641
661
finally :
642
662
os .close (fh )
0 commit comments