We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DocIO - Retrieve Caption for Image

Hi,

I am reading a Word document using DocIO and am trying to figure out how to read the Caption for an Image. The WPicture class has a method AddCaption but no method GetCaption or property Caption.

What I have noticed is that the Caption of an Image created in Word appears as a separate WParagraph, which makes things tricky. How can I tell which WParagraph instance contains the Caption text for a particular Image?

Please see an example of a Word document attached. What I am looking for is retrieving the "Google" text to save as part of the Image.

Using the AlternativeText is not an option as it does not support formatting (like hyperlinks, etc).

Thanks!

Erik

1 Reply

MJ Mohanaselvam Jothi Syncfusion Team September 14, 2017 01:40 PM UTC

Hi Erik,

Thank you for using Syncfusion product.

In Microsoft Word, the image caption can be added above or below of the image. It is also possible to add multiple captions for an image. There is not references or a link between captions and its corresponding images. So, it is not feasible to get the image based on the image caption. The “Caption” paragraph style is used to define the caption of an image. So, you can identify the image captions based on “Caption” paragraph style.

Essential DocIO also performs the same as per Microsoft word behavior. So it is not feasible to retrieve caption of image.

We have prepared a workaround to meet your requirement with the help bookmark navigators. In this workaround sample, we have done the following things:
   1.Create a word document and add image.
   2.When creating image, bookmark is added to it.
   3.When adding caption for image, the bookmark is extended to its caption.
   4.Navigate to the image using BookmarksNavigator and retrieved the contents within a bookmark.
   5.Then, retrieve the caption text of the image within the bookmark.


Please find the sample which illustrates the same from below link, and let us know if this helps you.
http://www.syncfusion.com/downloads/support/forum/132647/ze/RetrieveCaptionSample1419716432.zip


We have not found any input document as mentioned in previous update. So kindly provide us your input Word document along with the details of working scenario which is used at your end. So that we can analyze further on your exact requirement and provide you the proper solution with the modified sample at the earliest.


Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 


Loader.
Up arrow icon