Combining Word Documents - Page Break Issues


#1

Hi Guys,

When combining word documents, I expect each document that is appended onto the previous document to start on new page. In some cases documents are being appended a line after the end of the previous information on the document before it. In the majority of cases it works great but they are a few exceptions were the latter is happening. Do you guys know whats causing this and how it can be resolved?

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p> </o:p>

Many Thanks

Dave

#2

Hi Dave,

Thank you for considering Aspose.

Could you please post:

1) at least a pair of documents that are separated by just a line when combining
2) a snippet of code you are using for the combining?


#3

If you are copying and appending Section objects, then you can control how a section starts by setting the Section.PageSetup.SectionStart property.


#4

Hi dimitry

Sorry i wouldn't say the documents are seperated by just a line in some cases it could be 1 line or 3 its pretty random.

Heres a snippet of the code i've attached a template thats failing with its ouput :

case "Word":
// If all document items are to be output to a single document
if (strOutputDocumentFrequency == "Multi")
{
while (docOutput.Sections.Count > 0)
{
Aspose.Word.Section docSection = docOutput.Sections[0];

docOutput.Sections.RemoveAt(0);
docMulti.Sections.Add(docSection);
}
}
else
{
docOutput.Save(strOutputFile + ".doc",SaveFormat.FormatDocument);
xmlOutput.WriteElementString("File", strOutputFile + ".doc");
}
break;

Thanks in advance

Dave


#5
  1. Please download the latest version of the component unless you have already done it.

    2. Use the following code for copying sections:

    foreach(Section sourceSection in docOutput.Sections)
    {
    Section newSection = (Section)docMulti.ImportNode(sourceSection, true);
    newSection.PageSetup.SectionStart = SectionStart.NewPage;
    docMulti.Sections.Add(newSection);
    }

    Let us know if it helps.


#6

Hi Guys got the new version up and running Smile,

Tried your code and im getting ‘Section’ is an ambigious reference,
Any help here i haven’t the time to read how the new section functionality works [8-)]

Many Thanks

Dave


#7

Hi Dave,

Just try to use fully qualified names then:

foreach(Aspose.Word.Section sourceSection in docOutput.Sections)
{
Aspose.Word.Section newSection = (Aspose.Word.Section)docMulti.ImportNode(sourceSection, true);
newSection.PageSetup.SectionStart = SectionStart.NewPage;
docMulti.Sections.Add(newSection);
}


#8

Hey awesome that worked!

Thanks Dmitry