python - 如何在 python-docx 中将图片添加到页眉/页脚
问题描述
我想使用 python-docx 在页脚或页眉中添加徽标(jpg 或 png 格式的图片)。
有没有办法做到这一点?
解决方案
添加运行并在运行中添加图片:
document = Document()
section = document.sections[0]
header = section.header
paragraph = header.paragraphs[0]
run = paragraph.add_run()
run.add_picture("my-image.png")
有关使用页眉和页脚的更多文档在这里:
https ://python-docx.readthedocs.io/en/latest/user/hdrftr.html
推荐阅读
- swift - 更改字典数组中的值 swift 5
- java - 如何修复“预期的 URL 方案 'http' 或 'https' 但未找到冒号”错误?
- javascript - 在 Bokeh DataTable 错误中引用行/列的 JS 代码
- go - 如何在函数中添加一些行可变次数?
- java - 用于 JDK8 的 Rhino javascript JSR-223-wrapper 在哪里?
- alfresco - 在 Alfresco 中找不到类 org.alfresco.web.config.WebClientConfigBootstrap
- c# - 为什么 SaveFileDialog 包含韩文字符时会更改文件名?
- android - 连线内存不足:ffmpeg 库的 Java 堆空间错误
- javascript - vue js 没有正确显示 props 组件
- amazon-web-services - Terraform:如何始终为新实例生成“新鲜”的 EIP?