Quantcast
Channel: Adobe Community : Popular Discussions - InDesign SDK
Viewing all articles
Browse latest Browse all 78596

Placing image into anchored object

$
0
0

Hi all,

 

I wanna place an image into an inline / anchored item. This is my function:

 

ErrorCode PlaceImageIntoAnchoredObject( URI uri, const UIDRef& refAnchoredObject)

{

    ErrorCode res = 0;

 

    IDataBase* db = refAnchoredObject.GetDataBase();

 

    InterfacePtr<ICommand> importCmd( CmdUtils::CreateCommand( kImportResourceCmdBoss ) );

 

    InterfacePtr<IImportResourceCmdData> importCmdData( importCmd, IID_IIMPORTRESOURCECMDDATA );

 

    importCmdData->Set( db, uri, kSuppressUI );

 

    CmdUtils::ProcessCommand( importCmd );

   

    UID importUid = importCmd->GetItemListReference().At( 0 );

 

    do {

        UID linkUid = Utils<ILinkUtils>()->FindLink( refAnchoredObject );

        if( linkUid == 0 ) {

 

            res = Utils<IHierarchyUtils>()->AddToHierarchy(db, importUid, refAnchoredObject.GetUID());

           

            return kSuccess;

        }

   

        UIDRef linkRef( db, linkUid );

        if (!linkRef)

            break;

 

        InterfacePtr<ILink> link( linkRef, UseDefaultIID() );

        if( !link )

            break;

 

        UIDRef resRef( db, link->GetResource() );

 

        res = Utils<Facade::ILinkFacade>()->RelinkResource(resRef, uri, kSuppressUI);

    } while ( false);   

 

    return res;

}

 

It works if the anchored item already has an image inside. It will be replaced.

 

If there is no image inside, then the call AddToHierarchy() leads to loss of the "anchored" attribute of my frame.

Do I call the function with the reference of text box containing the anchored item, the image appears, but as "fly over" beside my anchored frame.


How can I assign my image to the anchored item?

 

If I manually "cut" the image, select the anchored frame, and "paste into selected item", the result is the wanted.

 

Who knows the trick?


Thanks, kb_alfa



Viewing all articles
Browse latest Browse all 78596


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>