Docker环境下Debian Jessie与Ubuntu的LibreOffice PDF转换差异排查
Great question—this is a super common gotcha when running headless LibreOffice conversion across older distros. The black blocks/lines you’re seeing almost always boil down to missing or outdated system packages that handle font rendering, graphics output, or LibreOffice’s underlying dependencies. Here’s the breakdown of key differences between Debian Jessie and Ubuntu 16.04 that are likely causing the problem:
Font & Font Configuration Packages
Ubuntu 16.04 ships with a more complete set of default fonts and updated font handling tools. Debian Jessie often lacks critical font packages likefonts-dejavu-core,fonts-liberation, andfonts-noto—these provide fallback fonts that prevent broken rendering when the original document uses fonts not present in the container. Additionally, Ubuntu 16.04 uses a newer version offontconfigthat handles font substitution and hinting far better than the older version in Jessie.Graphics Rendering Libraries
Headless LibreOffice relies on virtual X11 display tools (likexvfb) and OpenGL/Mesa libraries for rendering content. Debian Jessie may be missinglibgl1-mesa-glx—a library that enables hardware-accelerated graphics emulation. Without it, LibreOffice falls back to a buggy software renderer that produces black artifacts. Ubuntu 16.04 includes this library by default, along with an updated Mesa stack that fixes many rendering bugs.LibreOffice UI/Rendering Components
Even in headless mode, LibreOffice depends on some UI-related libraries to render content correctly. Ubuntu 16.04 includes packages likelibreoffice-gtk2orlibreoffice-gtk3by default, which provide critical rendering hooks. Debian Jessie’s minimal LibreOffice installation often omits these, leading to incomplete or broken rendering of complex elements (like shapes, images, or slide transitions if converting a presentation).System Library Versions
Debian Jessie uses older versions of core system libraries likelibc6andlibstdc++6compared to Ubuntu 16.04. These libraries power many of LibreOffice’s low-level operations, and the older versions in Jessie have known bugs related to memory management and graphics buffer handling that cause rendering glitches.
Quick Fix to Test in Debian Jessie
To verify these are the issues, install the missing packages in your Debian Jessie container:
apt-get update && apt-get install -y xvfb fonts-dejavu-core fonts-liberation libgl1-mesa-glx libreoffice-gtk2
Then run your conversion wrapped in xvfb-run to ensure proper virtual display handling:
xvfb-run libreoffice --headless --convert-to pdf --outdir ./output ./input/file.docx
内容的提问来源于stack exchange,提问作者Alkis Kalogeris

