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

Free Support Forum - aspose.com

Layout changing when appending a document

Hi,



in the attached sample you will see that appending a document to a new document will modify the original layout.

Please take a look,



Greetings

Hi Markus,


Please try using the following code with Aspose.Words for .NET 16.7.0:

License lic = new License();

lic.SetLicense("Aspose.Words.lic");

var document2 = new Document(@".\Document\test.docx");

Document document1 = (Document)document2.Clone(false);

document1.RemoveAllChildren();

document1.EnsureMinimum();

document1.AppendDocument(document2, ImportFormatMode.KeepDifferentStyles);

var filename = Path.GetTempPath() + Path.GetRandomFileName() + ".docx";

document1.Save(filename);

Console.WriteLine("saved document to : " + filename);

Process.Start(filename);

Console.ReadLine();


Best regards,

Hi Awais,

I think I have to explain a little further. Of course we do not only append one document to an empty document. We merge many different docs. At first to a blank document then to the steadily growing document.
So cloning the document and then stripping it to finally append it to ist former self does not seem to be an useful approach. :frowning:

Could you revise?

Greetings,
Markus

Hi Markus,


For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-14093. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience.

Best regards,

Hi Markus,


Regarding WORDSNET-14093, our product team has completed the work on your issue and has come to a conclusion that this issue is not a bug in Aspose.Words. Your issue (WORDSNET-14093) will be closed with ‘Not a Bug’ resolution. Please use the following code to fix this issue:

var document1 = new Document();

var document2 = new Document(MyDir + "test.docx");

document1.CompatibilityOptions.DoNotVertAlignCellWithSp = false;

document1.AppendDocument(document2, ImportFormatMode.KeepDifferentStyles);

document1.Save(MyDir + @"17.2.0-fixed.docx");


This option can be used to specify "Don't Vertically Align Cells Containing Floating Objects". Fixed output document is also attached with this post.

Hope, this helps.

Best regards,