@@ -111,29 +111,29 @@ def process_pdf_metadata(pdf_path, url):
111111
112112 total_pages = doc .page_count
113113 item_count = 0
114- hyperlink_id = create_data ()
115-
116- for page_idx in range (total_pages ):
117- cur_page = doc .load_page (page_idx )
118- links = cur_page .get_links ()
119- hyperlinks = []
120-
121- for item in links :
122- x0 , y0 , x1 , y1 = item ['from' ]
123- coordinates = [round (coord , 5 ) for coord in [x0 , y0 , x1 , y1 ]]
124- uri = item .get ('uri' , '' )
125- hyperlink = {'id' : f"{ hyperlink_id } -{ item_count } " , 'uri' : uri , 'coordinates' : coordinates }
126- hyperlinks .append (hyperlink )
127- item_count += 1
128-
129- json_data ['pages' ].append ({"hyperlinks" : hyperlinks })
130-
131- update_data (bin_id = hyperlink_id , json_data = json_data )
132- doc .close ()
114+ bin_id = create_data ()
115+ hyperlink_id = UID
116+ for page_idx in range (total_pages ):
117+ cur_page = doc .load_page (page_idx )
118+ links = cur_page .get_links ()
119+ hyperlinks = []
120+
121+ for item in links :
122+ x0 , y0 , x1 , y1 = item ['from' ]
123+ coordinates = [round (coord , 5 ) for coord in [x0 , y0 , x1 , y1 ]]
124+ uri = item .get ('uri' , '' )
125+ hyperlink = {'id' : f"{ hyperlink_id } -{ item_count } " , 'uri' : uri , 'coordinates' : coordinates }
126+ hyperlinks .append (hyperlink )
127+ item_count += 1
128+
129+ json_data ['pages' ].append ({"hyperlinks" : hyperlinks })
130+
131+ update_data (bin_id = hyperlink_id , json_data = json_data )
132+ doc .close ()
133133
134134def making_pdf_qr (path ):
135- pdfkit .from_url (path , output_path = TEMP_PDF_PATH , configuration = CONFIG , options = OPT , verbose = False )
136- num_pages = count_pdf_pages (TEMP_PDF_PATH )
135+ pdfkit .from_url (path , output_path = TEMP_PDF_PATH , configuration = CONFIG , options = OPT , verbose = False )
136+ num_pages = count_pdf_pages (TEMP_PDF_PATH )
137137 generate_qr_codes (num_pages )
138138 add_qr_codes_to_pdf (num_pages , TEMP_PDF_PATH , FINAL_PDF_PATH )
139139 os .remove (TEMP_PDF_PATH )
0 commit comments