爱意满满的作品展示区。
ponycool
0.04D

简易、轻量的文档转换 PDF

  •  
  •   ponycool · Sep 24, 2025 · 1801 views
    This topic created in 241 days ago, the information mentioned may be changed or developed.

    前言

    文档转 PDF 已经有非常多的成熟方案,例如 Pandoc 、JODConverter 、stirlingpdf 。相比这些成熟的方案就像一个简易的玩具。还有太多需要优化的地方:异步转换/消息队列、文件存储策略优化、LibreOffice 进程管理、并发安全、超时控制等等

    背景及开发过程

    现有的项目中有一个需求是需要根据文档估算预览时间,为了获取文档的页数先统一转换为 pdf 。考虑到简易、轻量、可控,基于 libreoffice 、gin 封装成 web 服务。 开发 90%的代码是 gemini 生成,gemini 生成 go 代码的准确度还是不错的。用了一天的时间调试代码,一天的时间处理 ci/cd 及脚本

    截图

    1 2 3 4

    GitHub

    GitHub

    仓库的 readme 是通义灵码生成,略有水分请忽略

    2 replies    2025-09-25 09:16:16 +08:00
    metalvest
        1
    metalvest  
       Sep 24, 2025 via Android
    说反了吧?基于 pandoc 应该比基于 libreoffice 轻量才对?
    ponycool
        2
    ponycool  
    OP
       Sep 25, 2025
    @metalvest 通过对比镜像,确实 pandoc 的镜像要小的多,libreoffice 的安装文件就有 382MB 。我的描述确实不够严谨,之前未做过详细对比

    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2742 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 02:21 · PVG 10:21 · LAX 19:21 · JFK 22:21
    ♥ Do have faith in what you're doing.