Generate name resolution items for pdf_dict. This may be either "/Names/Dests" or just "/Dests"
(dest_dict, pdf_dict)
| 6397 | return templ_dict |
| 6398 | |
| 6399 | def fill_dict(dest_dict, pdf_dict): |
| 6400 | """Generate name resolution items for pdf_dict. |
| 6401 | |
| 6402 | This may be either "/Names/Dests" or just "/Dests" |
| 6403 | """ |
| 6404 | # length of the PDF dictionary |
| 6405 | name_count = mupdf.pdf_dict_len(pdf_dict) |
| 6406 | |
| 6407 | # extract key-val of each dict item |
| 6408 | for i in range(name_count): |
| 6409 | key = mupdf.pdf_dict_get_key(pdf_dict, i) |
| 6410 | val = mupdf.pdf_dict_get_val(pdf_dict, i) |
| 6411 | if key.pdf_is_name(): # this should always be true! |
| 6412 | dict_key = key.pdf_to_name() |
| 6413 | else: |
| 6414 | message(f"key {i} is no /Name") |
| 6415 | dict_key = None |
| 6416 | |
| 6417 | if dict_key: |
| 6418 | dest_dict[dict_key] = get_array(val) # store key/value in dict |
| 6419 | |
| 6420 | # access underlying PDF document of fz Document |
| 6421 | pdf = mupdf.pdf_document_from_fz_document(self) |