Documentation
¶
Overview ¶
Package office 通过 LibreOffice 命令行把 Office 文档(docx/doc/odt/rtf/wps/ pptx/xlsx 等)转换为 PDF。转换依赖目标机器已安装 LibreOffice,本包只做进程 调用与临时文件管理,不引入任何第三方依赖。
Index ¶
Constants ¶
View Source
const DefaultTimeout = 2 * time.Minute
DefaultTimeout 是单次转换的默认超时时间。
View Source
const EnvSoffice = "OFD_SOFFICE"
EnvSoffice 是覆盖 LibreOffice 可执行文件路径的环境变量名。
Variables ¶
This section is empty.
Functions ¶
func ConvertToPDF ¶
ConvertToPDF 把 inputPath 转换为 PDF 并返回 PDF 字节。inputPath 必须是 可读的本地文件;转换在独立临时目录和独立用户配置目录中进行,互不干扰。
func FindSoffice ¶
FindSoffice 定位 LibreOffice 可执行文件。查找顺序为:显式路径、 OFD_SOFFICE 环境变量、PATH 中的 soffice/libreoffice、平台常见安装路径。 找不到时返回错误,调用方应据此给出可操作的提示。
Types ¶
Click to show internal directories.
Click to hide internal directories.