• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get selected images?

Guest
Mar 14, 2013 Mar 14, 2013

Copy link to clipboard

Copied

Hi all,

can anyone help with getting a list of selected images?

E.g., to get selected tables I use

doc.GetTextForRange(doc.TextSelection, Constants.FTI_TblAnchor)

Thanks in advance!

TOPICS
Scripting

Views

900

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2013 Mar 14, 2013

Copy link to clipboard

Copied

If you want the anchored frames in a range of selected text, you would use

var textList = doc.GetTextForRange(doc.TextSelection, Constants.FTI_FrameAnchor);

If you want to get graphics that are selected as objects, you can use:

var graphic = doc.FirstSelectedGraphicInDoc;

while (graphic.ObjectValid()) {

    // Do something here.

    graphic = graphic.NextSelectedGraphicInDoc;

}

Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 15, 2013 Mar 15, 2013

Copy link to clipboard

Copied

Thanks for the answer. The main goal is to get to the text in the image description. Can you say, what way is better for this purpose?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2013 Mar 15, 2013

Copy link to clipboard

Copied

You will have to explain how things are set up, or maybe post a screenshot. I don't know what you mean by "text in the image description." Thanks.

Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 15, 2013 Mar 15, 2013

Copy link to clipboard

Copied

LATEST

Suppose you have a document and have a picture in it. Under the picture there's a hint/title/description "Picure 2.3. A snow falling in the UK."

As I found out, this text can be obtained trough FrameAnchor from your suggestion.

var imgHintList =  doc.GetTextForRange(doc.TextSelection, Constants.FTI_FrameAnchor);

var imgHint = imgHintList[imgIndex].obj.TextLoc;

This works good. The part that I'm working on now is how to limit the search with only this Hint. Th algorythm is:

1. Search a word in a hint.

2. Replace it with another.

3. Start the search again, but starting from the end of our replacement.

4. Repeat while we have any finds.

For now, I can search and replace all info, but I can't stop when the search reaches the end of the Hint. Here's what I have:

findParam = AllocatePropVals (1);

findParam[0].propIdent.num = Constants.FS_FindText;

findParam[0].propVal.valType = Constants.FT_String;

//.... some code

var imgHintList =  doc.GetTextForRange(doc.TextSelection, Constants.FTI_FrameAnchor);

for(var imgIndex = 0; imgIndex < imgHintList.length; imgIndex++){

     var imgHint = imgHintList[imgIndex].obj.TextLoc;

     findParam[0].propVal.sval = strings[1];           

     foundText = doc.Find (imgHint, findParam);

     testText = doc.GetTextForRange (foundText, Constants.FTI_String);                 

                

     while(testText.length > 0){ // here, probably, should be an extra stop condition ....

          doc.DeleteText(foundText);

          doc.AddText(foundText.beg, strings[2]);

            

          //starting the search from the end of the replaced block

          imgHint.offset = foundText.end.offset;                    

          foundText = doc.Find (imgHint, findParam);

          testText = doc.GetTextForRange (foundText, Constants.FTI_String);

     }

}

Any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines