Hello,
I am using code below in a loop. Whenever I appendDocument it inserts a page break, is there anyway that I can have my data append in same page instead of new page every time?
Dim mobjMainAsposeDoc As Aspose.Words.Document = New Aspose.Words.Document
Dim lobjAppendDoc As New Aspose.Words.Document(System.IO.Path.GetTempPath & "TempAppend.Doc")
mobjMainAsposeDoc.AppendDocument(lobjAppendDoc, ImportFormatMode.KeepSourceFormatting)
Also after my loop is done I wish to apply Mirror Margin to mobjMainAsposeDoc object. or Editor Control How can I do that.
Thanks in advance for your time
Vinay Hattarki
Hi
Thanks for your request. You should use SectionStart.Continouse in this case. Please see the following code:
// Open destination document
Document dstDoc = new Document(@"Test132\in.doc");
// Get list of source documents
string[] srcFiles = Directory.GetFiles(@"Test132\src\", "*.doc");
// Loop through all files
foreach (string name in srcFiles)
{
// Open document
Document srcDoc = new Document(name);
// Set SectionStart of first section
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
// Append document
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
}
// Here you can change margins of all sections.
foreach (Section sect in dstDoc.Sections)
{
sect.PageSetup.LeftMargin = 100;
sect.PageSetup.RightMargin = 100;
}
// Save output document
dstDoc.Save(@"Test132\out.doc");
Hope this helps.
Best regards.