Duplicit

Hello, I've encountered some strange behaviour when working with WPicture.AddCaption method. It doubles the entered name. Here is a little snippet of code I use to build a table of images with captions:

WTable table = (WTable)section.AddTable();
table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.None;
table.TableFormat.CellSpacing = 10;
int count = (images.Count / 2) + 1;
table.TableFormat.HorizontalAlignment = RowAlignment.Center;
if (count > 0)  {
   table.ResetCells(count, 2);
   int row = 0;
   for (int i = 0; i < images.Count(); i++) {
        int pos = i % 2;
        Bitmap image = images[i].Image;
        WParagraph imagePar = (WParagraph)table[row, pos].AddParagraph();
        WPicture picture = (WPicture)imagePar.AppendPicture(image);
        picture.TextWrappingStyle = TextWrappingStyle.Inline;
        picture.LockAspectRatio = true;
        picture.AddCaption(images[i].Label, CaptionNumberingFormat.Number, CaptionPosition.AfterImage);
        this.ApplyFormattingForCaption(imagePar);
        if (pos > 0) {
             row++;
        }
}

And it works really fine, except that the image caption string is printed twice, for the second time seemingly in 

encoded form (see " _ " instead of " " etc. ). See the image sample below:


Please note that the images[i].Label contains the name just once, the second string is not the name of the text and my document contains plenty of other text and this problem does not occur anywhere else.


Any help or workaround would be greatly appreciated.

Thank you,

Petr


2 Replies 1 reply marked as answer

MR Manikandan Ravichandran Syncfusion Team October 21, 2021 07:18 AM UTC

Hi Petr,

Thank you for contacting Syncfusion support.

We have reproduced the reported problem using the given code example and we have found that we are missed to update the document fields after inserting the image caption. So that, the captions are added as twice.

We have modified the code example and the modified sample can be download from the below link.
https://www.syncfusion.com/downloads/support/forum/169809/ze/ConsoleAppBase_F169809-1983668311

Please refer the below link to know more about Add image caption.
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#add-image-caption

Please let us know if you have any other
queries.

Regards,
Manikandan Ravichandran
 


Marked as answer

PE Petr November 24, 2021 03:32 PM UTC

Thank you very much!


Loader.
Up arrow icon