IronPDF 故障排除 AWS Lambda上的字体损坏 Broken Font on AWS Lambda Curtis Chau 已更新:六月 1, 2025 Download IronPDF NuGet 下载 DLL 下载 Windows 安装程序 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English 在 Linux 中渲染 PDF 文档可能会导致字符损坏,如下图所示。 有时字符在 Windows 环境中显示正常,但在 Linux 中却不正常。 原因 原因是操作系统缺少该字体。 解决方案 如果您已经知道字体名称,那就很好——您可以跳过步骤 1。 要找出字体名称,请尝试在 Windows 上渲染 HTML,并使用 Adobe 检查字符。 一旦确定了字体名称,您可以在线下载字体文件,例如从Google Fonts下载。 要通过 Dockerfile 添加和安装字体,请将字体放入项目中,并将 '复制到输出目录' 设置为 '始终复制'。接下来,使用以下代码在 Dockerfile 中添加并安装它: # Copy the Cambria Math font into the container # Ensure the font file (cambria.ttc) exists in your project directory COPY cambria.ttc /usr/share/fonts/ # Install fontconfig to update the font cache # This will install fontconfig and refresh the font cache to recognize the newly added fonts RUN dnf install -y fontconfig && \ fc-cache -fv 解释 COPY cambria.ttc /usr/share/fonts/:此行将 Cambria Math 字体从您的项目目录复制到容器的字体目录中。 确保字体文件(cambria.ttc)存在于项目目录中。 RUN dnf install -y fontconfig && \:此命令安装 fontconfig 包,该包对于管理和配置 Linux 中的字体访问是必要的。 -y 标志自动确认包的安装。 fc-cache -fv:此命令更新字体缓存,确保新复制的字体在容器内的应用程序中可用。 标志 -f (强制)和 -v (详细)用于强制重新生成缓存并提供详细输出。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:16,154,058 查看许可证