After Copying a Table from One Presentation to Another in C#, the Clone Size Is Reported Incorrectly

Using this code:

 private void CopyWorkbookRangeToPresentation(Range sourceRange, Presentation targetPresentation)
 {
     // Copy the specified range to an intermediate workbook.
     Workbook intermediateWorkbook = IsolateSourceRangeInAsposeWorkbook(sourceRange);

     // Create a presentation from the intermediate workbook.
     Presentation sourcePresentation = CreatePresentationFromAsposeWorkbook(intermediateWorkbook);
     foreach (IShape shape1 in targetPresentation.Slides[0].Shapes)
         if (shape1 is Table table)
             Debug.WriteLine($"sourcePresentation -> Height: {table.Height}; Width: {table.Width}");

     // Add the first shape in the source presentation to the target presentation.
     IShape shape = targetPresentation.Slides[0].Shapes.AddClone(sourcePresentation.Slides[0].Shapes[0]);

     foreach (IShape shape1 in targetPresentation.Slides[0].Shapes)
         if (shape1 is Table table)
             Debug.WriteLine($"After create -> Height: {table.Height}; Width: {table.Width}");

     MemoryStream memoryStream = new MemoryStream();
     targetPresentation.Save(memoryStream, Aspose.Slides.Export.SaveFormat.Pptx);

     Presentation fixedPresentation = new Presentation(memoryStream);

     foreach (IShape shape1 in fixedPresentation.Slides[0].Shapes)
         if (shape1 is Table table)
             Debug.WriteLine($"After fixed -> Height: {table.Height}; Width: {table.Width}");

     shape.X = 72;
     shape.Y = 72;
 }

You can see that after cloning the table from the source presentation to the target presentation the size of the new table is reported incorrectly. Saving the target presentation to a memorty stream and then reloading it as a new presentation the size of the table is reported correctly.

OUTPUT FROM DEBUG STATEMENTS:

BEFORE CLONING:

sourcePresentation → Height: 182.76488; Width: 461.64938
sourcePresentation → Height: 182.76488; Width: 461.64938
sourcePresentation → Height: 182.76488; Width: 461.64938

AFTER CLONING:

After create → Height: 182.76488; Width: 461.64938
After create → Height: 182.76488; Width: 461.64938
After create → Height: 182.76488; Width: 461.64938
After create → Height: 612.75; Width: 792.75 (THIS IS THE NEW TABLE CLONE)

AFTER SAVING TO A STREAM AND REOPENING:

After fixed → Height: 182.76488; Width: 461.64938
After fixed → Height: 182.76488; Width: 461.64938
After fixed → Height: 182.76488; Width: 461.64938
After fixed → Height: 182.76488; Width: 461.64938 (THIS IS THE NEW TABLE CLONE)

I continued to work with this and found the just saving to memory fixed the issue. I didn’t have to reinstantiate the presentation.

@kippow,
Thank you for contacting support. We are glad to know that the issue has been resolved on your end. If you have any questions, please let us know.