2121# processor_id = 'YOUR_PROCESSOR_ID' # Create processor in Cloud Console
2222# file_path = '/path/to/local/pdf'
2323
24+
2425def process_document_form_sample (
2526 project_id : str , location : str , processor_id : str , file_path : str
2627):
@@ -69,9 +70,9 @@ def process_document_form_sample(
6970 for table in page .tables :
7071 num_collumns = len (table .header_rows [0 ].cells )
7172 num_rows = len (table .body_rows )
72- print (f' Table with { num_collumns } columns and { num_rows } rows:' )
73+ print (f" Table with { num_collumns } columns and { num_rows } rows:" )
7374 print_table_info (table , text )
74- print (f' Found { len (page .form_fields )} form fields:' )
75+ print (f" Found { len (page .form_fields )} form fields:" )
7576 for field in page .form_fields :
7677 name = layout_to_text (field .field_name , text )
7778 value = layout_to_text (field .field_value , text )
@@ -80,17 +81,17 @@ def process_document_form_sample(
8081
8182def print_table_info (table : dict , text : str ) -> None :
8283 # Print header row
83- header_row_text = ''
84+ header_row_text = ""
8485 for header_cell in table .header_rows [0 ].cells :
8586 header_cell_text = layout_to_text (header_cell .layout , text )
86- header_row_text += f' { repr (header_cell_text .strip ())} | '
87- print (f' Collumns: { header_row_text [:- 3 ]} ' )
87+ header_row_text += f" { repr (header_cell_text .strip ())} | "
88+ print (f" Collumns: { header_row_text [:- 3 ]} " )
8889 # Print first body row
89- body_row_text = ''
90+ body_row_text = ""
9091 for body_cell in table .body_rows [0 ].cells :
9192 body_cell_text = layout_to_text (body_cell .layout , text )
92- body_row_text += f' { repr (body_cell_text .strip ())} | '
93- print (f' First row data: { body_row_text [:- 3 ]} \n ' )
93+ body_row_text += f" { repr (body_cell_text .strip ())} | "
94+ print (f" First row data: { body_row_text [:- 3 ]} \n " )
9495
9596
9697def layout_to_text (layout : dict , text : str ) -> str :
0 commit comments