Betsy,
looks like I found workaround.
If I change my code and move line
- Code: Select all
section.HeadersFooters.LinkToPrevious = False
from the loop and apply it only for first section - it works.
But if I merge, say, 10 documents - this works only for second merged document.
Therefore when merging multiple documents into single pdf
workaround is to apply
- Code: Select all
section.HeadersFooters.LinkToPrevious = False
ONLY to the first section of each merged document.
Final code for multiple documents will be something like this:
- Code: Select all
Dim sdoc As New Spire.Doc.Document
sdoc.LoadFromFile("test_page_headers.docx")
For Each file As String In files
Dim sdoc2 As New Spire.Doc.Document
sdoc2.LoadFromFile(file)
Dim is_first_section = True
For Each sec As Spire.Doc.Section In sdoc2.Sections
Dim section = sec.Clone()
sdoc.Sections.Add(section)
'also important note - the following code MUST be after sdoc.Sections.Add as for some reason if it's before - issue still be reproduced
If is_first_section Then
section.HeadersFooters.LinkToPrevious = False 'fix headers/footers
is_first_section = False
End If
Next sec
Next
sdoc.SaveToFile("result.pdf", Spire.Doc.FileFormat.PDF)
Thanks, Oleg