Image caption does not include numbering

Hi,

I am using the following code to add an image to a report: 

            IWPicture image = paragraph.AppendPicture(imageInfo.Source);

            paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;


            if (imageInfo.Text is not null)

            {

                var caption = image.AddCaption("Image" + " - Figure:", CaptionNumberingFormat.Number, CaptionPosition.AfterImage);

                caption.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;

                caption.ParagraphFormat.BeforeSpacing = 1.5f;

            }


but it is adding text rather than the desired image number. 

Please see the attached report for an example of the output caption on the image. 


Attachment: Image_Caption_f22927f6.zip

1 Reply 1 reply marked as answer

SB Suriya Balamurugan Syncfusion Team June 11, 2024 06:57 AM UTC

Hi Natalie,

On further analyzing of the given code snippet, we found that you have added a caption to an image and updated the caption numbers (sequence fields) using the AddCaption method. To achieve your requirement, we suggest that you to update the fields in the Word document by calling the UpdateDocumentFields() API after adding the caption to the image.

Please refer to the highlighted code snippet below to achieve your requirement.



Please refer to our UG documentation link to know about how to add a caption to an image,
Add Image caption

Additionally, you can refer to the working sample on GitHub.

Note: If this post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.

Regards,
Suriya Balamurugan.


Marked as answer
Loader.
Up arrow icon