Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Sat Feb 01, 2020 9:46 am

Hello
UPDATE : Crazy, Clone() is not the root problem
1) docx with a shapegroup with two simple shapes
2) new document(this one)
3) savetofile docx with a new name --> exception

RQ : saving to PDF format does'nt throw the exception

Code: Select all
    public void DoSimpleTest()
    {
      string inputDocxName = Path.Combine(Application.StartupPath, "ShapeGroupTemplate.docx");
      string outputDocxName = Path.Combine(Application.StartupPath, $"ShapeGroupTest {DateTime.Now:yyyy-MM-dd HH-mm-ss}.docx");
      string outputPdfName = Path.Combine(Application.StartupPath, $"ShapeGroupTest {DateTime.Now:yyyy-MM-dd HH-mm-ss}.pdf");
      using (Document inputDoc = new Document(inputDocxName))
      {
        inputDoc.SaveToFile(outputDocxName, FileFormat.Docx);
        Process.Start(outputDocxName);
        inputDoc.SaveToFile(outputPdfName, FileFormat.PDF);
        Process.Start(outputPdfName);
        inputDoc.Close();
      }
    }

I'm testing v8.1.10

My template docx contains a shapegroup with two simple shapes.
I need to copy (clone) this one in a new document docx.
When saving this new docx, I have an exception
"Impossible d'effectuer un cast d'un objet de type 'System.Drawing.Color' en type 'sprᭉ'."

Code: Select all
    public void DoTest()
    {
      string bookmarkName = "ShapeGroup";
      string inputDocxName = Path.Combine(Application.StartupPath, "ShapeGroupTemplate.docx" );
      string outputDocxName = Path.Combine(Application.StartupPath, $"ShapeGroupTest {DateTime.Now:yyyy-MM-dd HH-mm-ss}.docx");
      string outputPdfName = Path.Combine(Application.StartupPath, $"ShapeGroupTest {DateTime.Now:yyyy-MM-dd HH-mm-ss}.pdf");
      using (Document inputDocx = new Document(inputDocxName))
      {
        BookmarksNavigator nav = new BookmarksNavigator(inputDocx);
        nav.MoveToBookmark(bookmarkName);
        ShapeGroup shapeGroup = GetShapeGroup(nav);
        using (Document outputDoc = new Document())
        {
          Section section = outputDoc.AddSection();
          Paragraph paragraph = section.AddParagraph();
          ShapeGroup clone = shapeGroup.Clone() as ShapeGroup;
          paragraph.ChildObjects.Add(clone);
          outputDoc.SaveToFile(outputDocxName, FileFormat.Docx);
          Process.Start(outputDocxName);
          outputDoc.SaveToFile(outputPdfName, FileFormat.PDF);
          Process.Start(outputPdfName);
          outputDoc.Close();
        }
        inputDocx.Close();
      }
    }

    private ShapeGroup GetShapeGroup(BookmarksNavigator nav)
    {
      foreach (var item in nav.GetBookmarkContent().BodyItems)
      {
        if (item is Paragraph)
        {
          foreach (var item1 in (item as Paragraph).ChildObjects)
          {
            if (item1 is ShapeGroup)
            {
              return item1 as ShapeGroup;
            }
          }
        }
      }
      return null;
    }
You do not have the required permissions to view the files attached to this post.

danielhalte1
 
Posts: 23
Joined: Sat Dec 14, 2019 12:50 am

Mon Feb 03, 2020 3:18 am

Hi,

Sorry for late reply as weekend.
I have reproduced the issue and logged it in our bug tracking system with the ticket SPIREDOC-3878. We will let you know once there is any update.
Sorry for the inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Wed Feb 12, 2020 10:27 am

Hi,

Glad to inform you theSPIREDOC-3878 has been solved in Spire.Doc Pack(hot fix) Version:8.2.4. Welcome to download it from the following link.
Our website: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget: https://www.nuget.org/packages/Spire.Doc/8.2.4

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Mon Feb 17, 2020 6:48 am

Hi,

Hope you are doing well.
Did you try the hotfix? Has your issue been resolved?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Mon Feb 24, 2020 12:17 pm

Hello
I confirm that the v8.2.9 fixes the problem. The ShapeGroup of my test is saved without problem

danielhalte1
 
Posts: 23
Joined: Sat Dec 14, 2019 12:50 am

Tue Feb 25, 2020 2:03 am

Hi,

Thanks for your feedback.
If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc