@@ -896,7 +896,7 @@ def _update_field_annotation(
896
896
897
897
def update_page_form_field_values (
898
898
self ,
899
- page : PageObject ,
899
+ page : Union [ PageObject , List [ PageObject ], None ] ,
900
900
fields : Dict [str , Any ],
901
901
flags : FieldFlag = OPTIONAL_READ_WRITE_FIELD ,
902
902
auto_regenerate : Optional [bool ] = True ,
@@ -908,8 +908,10 @@ def update_page_form_field_values(
908
908
If the field links to a parent object, add the information to the parent.
909
909
910
910
Args:
911
- page: Page reference from PDF writer where the
911
+ page: `PageObject` - references ** PDF writer's page** where the
912
912
annotations and field data will be updated.
913
+ `List[Pageobject]` - provides list of page to be processsed.
914
+ `None` - all pages.
913
915
fields: a Python dictionary of field names (/T) and text
914
916
values (/V).
915
917
flags: An integer (0 to 7). The first bit sets ReadOnly, the
@@ -925,6 +927,14 @@ def update_page_form_field_values(
925
927
raise PyPdfError ("No /Fields dictionary in Pdf in PdfWriter Object" )
926
928
if isinstance (auto_regenerate , bool ):
927
929
self .set_need_appearances_writer (auto_regenerate )
930
+ # Iterate through pages, update field values
931
+ if page is None :
932
+ page = list (self .pages )
933
+ if isinstance (page , list ):
934
+ for p in page :
935
+ if PG .ANNOTS in p : # just to prevent warnings
936
+ self .update_page_form_field_values (p , fields , flags , None )
937
+ return None
928
938
if PG .ANNOTS not in page :
929
939
logger_warning ("No fields to update on this page" , __name__ )
930
940
return
0 commit comments