python - 使用python docxcompose合并文档,不同的header如何处理?
问题描述
我有很多文档,这些文档只有一页,但标题不同,我使用pythondocxcompose
合并这些文档,但是这个操作会将所有标题更改为第一个文档或主文档,有什么办法避免这个?我只是希望这些文件有不同的标题。
我在is_linked_to_previous=False
合并这些文档时添加,但它不起作用
这是我使用的代码:
def megerDocToOne(self, seperatepath, megerpathAndFileName):
original_docx_path = seperatepath
new_docx_path= megerpathAndFileName
all_word=os.listdir(original_docx_path)
all_file_path=[]
for file_name in all_word:
all_file_path.append(original_docx_path+file_name)
master=Document(all_file_path[0])
middle_new_docx=Composer(master)
num=0
for word in all_file_path:
word_document=Document(word)
word_document.add_section(WD_SECTION_START.NEW_PAGE)
header = word_document.sections[0].header
header.is_linked_to_previous = False
if num!=0:
middle_new_docx.append(word_document,True)
num=num+1
middle_new_docx.save(new_docx_path)
解决方案
推荐阅读
- javascript - 配置 Enzyme 3.x 适配器
- python - Flask SQLAlchemy 强制连接
- linux-kernel - 如何解决内核配置无效的问题
- selenium - 使用 Appium 或 Perfecto 使用 amCharts 元素自动化 iOS 应用程序
- android - Android Wear 打包分发
- netflix-eureka - 如何在 eureka 服务器上为每个 eureka 客户端注册多个服务?
- java - 从 mutator 更改后 Java 程序不使用新值
- valgrind - valgrind 生成非常大的 xtree
- objective-c - 如何从可折叠 UITableViewCell 中播放视频?
- python - SQL 数据类型错误:无法在 SQL 表的列中输入字符