通过libreoffice将.docx文件转换为pdf时,超链接断开

发布于 2025-02-07 07:33:06 字数 818 浏览 1 评论 0原文

我正在尝试将.docx文件转换为.pdf通过soffice,使用以下命令:

soffice --convert-to pdf input.docx --outdir <outdir>

转换成功而没有任何错误。但是,超链接不起作用。文件中的超链接是指向同一目录中其他PDF文件的相对链接。

超链接不起作用 - 无论我使用哪种PDF读取器,超链接都无法单击。

我尝试以下内容来缩小问题:

  • 在Libreoffice中打开文档,并“编辑”第一个超链接,打开并关闭对话框而无需做任何事情。
  • 将.docx文件保存在libreoffice中,然后通过soffice运行无头转换CLI。
  • 观察到只有第一个超链接工作 - 我们“编辑”的一个无需更改任何内容。

我打开了实际的.docx内部内容,发现_RELS文件完全相同。唯一的区别是,我“编辑”的超链接在word/document.xml中具有此附加标签:

<w:rStyle w:val="InternetLink" />

有些搜索我找到了

我的问题是 - 如何使用soffice.docx转换为.pdf在保留超链接时?我可以对Libreoffice源代码进行代码更改?

I'm attempting to convert .docx files to .pdf via soffice, using the following command:

soffice --convert-to pdf input.docx --outdir <outdir>

The conversion succeeds without any error. However, the hyperlinks do not work. The hyperlinks in the file are relative links to other PDF files in the same directory.

The hyperlinks do not work - no matter what PDF reader I use, the hyperlinks aren't clickable.

I tried the following to narrow down my issue:

  • Open the document in LibreOffice and “edit” the first hyperlink, open and close the dialog without doing anything.
  • Save the .docx file in LibreOffice, and then run the headlesss conversion CLI via soffice.
  • Observe that only the first hyperlink works - the one we “edited” without changing anything.

I opened the actual .docx internals, and found the _rels files were exactly identical. The only difference was that the hyperlink I “edited” had this additional tag in the word/document.xml:

<w:rStyle w:val="InternetLink" />

Some googling me found this unanswered issue. It appears that LibreOffice expects the InternetLink property to be present when converting hyperlinks to pdf.

My question is - how can I use soffice to convert the .docx to .pdf while retaining hyperlinks? Is there a code change I can make to the LibreOffice source code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文