We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Section Breaks when appending documents

Is it possible to not automatically insert a section break when appending one document to another ?

Apologies, I think I was way too terse with my question.

When I am constructing a document using the append method, Aspose automatically creates section breaks between the documents, I know that I can use SectionStart.Continuous to make it appear as if there are "no" sections, however thes issue I am having is that the headers and footers whch are defined in a template document do not appear correctly in the destination document. As far as I can tell it is directly related to the automatic creation of section breaks between appended documents.

Is there a way to append documents so that they all become part of a single section (section breaks in the individual documents notwithstanding) ?

The code I am using to construct the destination document is as follows:

    Public Shared Function Build(DocsToUse() As String, Template As String) As Document
        Dim Doc As New Document(Template)
        Doc.AttachedTemplate = Template
    	For Each t as String in DocsToUse
   	 AppendDoc(Doc, d)
    <span style="color: blue;">Return</span> Doc
<span style="color: blue;">End</span> <span style="color: blue;">Function</span>

    Public Shared Sub AppendDoc(Doc As Document, Src As String)
Dim tDoc As New Document(Src)
tDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous
For Each sect As Section In tDoc.Sections
Doc.AppendDocument(tDoc, ImportFormatMode.UseDestinationStyles)
End Sub

Hopefully I have a bit clearer about the issue I am having.

Many thanks


Thanks for your interest in Aspose.Words. Documents are appended at the section level therefore the PageSetup.SectionStart property of the Section object defines how the content of the current section is joined in relation to the previous section. If the PageSetup.SectionStart property is set to SectionStart.NewPage for the first section in the source document then the content in this section is forced to start on a new page. Conversely if the property is set to SectionStart.Continuous then the content is allowed to flow on the same page directly after the previous section’s content.

Headers/Footers exist at Section level therefore if you copy a Section to another Document, the Headers/Footers are also copied. I think, in your case, to insert the content of one document to another at an arbitrary location the simple InsertDocument method presented here can be used.

Please let me know if I can be of any further assistance.

Best regards,