通过libreoffice将.docx文件转换为pdf时,超链接断开
我正在尝试将.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 viasoffice
. - 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论