docpreview

package
v0.4.72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docpreview 把任务里抓到的 Office / PDF 文档取样渲染成图片: Office(doc/xls/ppt/csv)先经 LibreOffice 转 PDF,再用 poppler 的 pdftoppm 渲染前 N 页为 JPEG。只做无状态的转换,落库/排队由调用方负责。

Index

Constants

View Source
const DefaultPages = 3

DefaultPages 是每份文档的取样页数上限。

Variables

View Source
var (
	ErrSofficeMissing  = errors.New("未安装 LibreOffice(soffice)")
	ErrPdftoppmMissing = errors.New("未安装 poppler-utils(pdftoppm)")
)

ErrSofficeMissing / ErrPdftoppmMissing 让调用方能区分“依赖没装”和“文档坏了”。

Functions

func Available

func Available() (soffice, pdftoppm bool)

Available 报告两个依赖是否齐全(宿主环境页/排障用)。

func Generate

func Generate(ctx context.Context, src, outDir string, maxPages int) (int, error)

Generate 把 src 渲染到 outDir/page-1.jpg...,最多 maxPages 页,返回实际页数。 outDir 会被创建(已存在则覆盖同名页文件);临时文件自动清理。

func KindFor

func KindFor(name string) string

KindFor 按扩展名判断文档类型;返回空串表示不支持预览。 Kubernetes 无关;命名与 server 的 artifact kind 对齐:document/spreadsheet/ presentation/pdf。

func Supports

func Supports(name string) bool

Supports 报告该文件是否可生成预览。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL