简体   繁体   English

在Excel文件中获取指向PDF中特定页面的超链接

[英]Getting a hyperlink inside an excel file that directs to a specific page in a PDF

The goal is to have multiple links in a column of an excel file which when clicked open a pdf to a specific page. 目的是在excel文件的列中具有多个链接,单击这些链接可打开pdf到特定页面。

According to this: https://helpx.adobe.com/acrobat/kb/link-html-pdf-page-acrobat.html 据此: https : //helpx.adobe.com/acrobat/kb/link-html-pdf-page-acrobat.html

What I've tried : 我尝试过的

# doc_path : path/to/file.pdf
pages_to_get = [1, 5, 88, 157]
# bytes_io = io.BytesIO()
writer = pd.ExcelWriter(path='abc.xlsx', engine='xlsxwriter')
workbook = writer.book
main_df = pd.DataFrame()
main_df.to_excel(writer, index=False,sheet_name='main')
main_sheet = writer.sheets['main']
doc_prefix = 'file://'
# doc_prefix = 'internal:file://'

for p in range(len(pages_to_get)):
    page_url = str(doc_prefix+ doc_path + '#page=' + str(pages_to_get[p]))
    print(page_url)
    main_sheet.write_url(col=2, row=(p + 1), url=page_url, string='Go To Page'+str(pages_to_get[p]))

writer.save()
writer.close()

But the issue is that the hyperlinks in the excel file only open the pdf to the first page. 但是问题是excel文件中的超链接仅打开pdf到首页。

事实证明,无法直接使用pdf进行此操作,但是您可以将pdf转换为其他格式(例如HTML)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM