I have many documents, and these documents only have one page, but it have different header, I use python docxcompose to merger these documents ,but this operation will change all the header to the first document or the master document, is there any way to avoid this? I just want these documents have different header.
I add the is_linked_to_previous=False while I merge these documents, but it did not work
This is the code I an using:
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)