Hello Team,
I am trying to append one by one pages from one document to another document then output document in some paragraph line alignment getting disturb. Its by default set to justify alignment.
Snippet :
Aspose.Words.Document outputDoc = new Aspose.Words.Document();
outputDoc.RemoveAllChildren();
byte[] sectionData;
Aspose.Words.Document sourceDoc = (Aspose.Words.Document)outputDoc.Clone(false);
sourceDoc.RemoveAllChildren();
sectionData = Encoding.UTF8.GetBytes(@"C:\\sourceDoc.docx");
sourceDoc = new Aspose.Words.Document(new MemoryStream(sectionData));
for (int j = 0; j < sourceDoc.PageCount; j++)
{
Aspose.Words.Document Page = (Aspose.Words.Document)sourceDoc.Clone(false);
Page.RemoveAllChildren();
Page = sourceDoc.ExtractPages(j, 1);
var pageText = Page.FirstSection.Body.ToString(SaveFormat.Text) + Page.LastSection.Body.ToString(SaveFormat.Text);
var shapeCount = Page.FirstSection.Body.GetChildNodes(Aspose.Words.NodeType.Shape, true).Count + Page.LastSection.Body.GetChildNodes(Aspose.Words.NodeType.Shape, true).Count;
if (string.IsNullOrEmpty(pageText.Trim()) && shapeCount == 0)
continue;
outputDoc.AppendDocument(Page, ImportFormatMode.KeepSourceFormatting);
}
outputDoc.Save(@"C:\\outputDoc.docx");
sourceDoc.docx (192.9 KB)
outputDoc.docx (47.5 KB)
Please refer below screen shorts: