How to place web link URL image into indesign graphic page item
Hello All,
I am trying to place simple web link url image into indesign graphic page item.The version SDK is CC 2017 on Mac. Steps are below
1.First I have converted web url into indesign URI (Note : I am using web browser preview jpeg link.)
2.From indesign URI I have created link resource UID.
3.With help of link resource UID and page item UID I have created bidirectional lik type.
4.Finally I have attached link.
5.I have tried to place file by kImportAndPlaceGunCmdBoss and SDKLayoutHelper to place the file by using created link resource but unable to see the image on document.
Problem: Its creating and linking page item successfully but unable to see image in frame. Also it showing "Macintosh HD" before http url link.
Is it required to download the web url image to relink?
Code is as below
URI httpURI;
IDFile idFilehttp;
PMString shttpFile("https://googlechrome.github.io/samples/picture-element/images/butterfly.jpg ");
FileUtils::PMStringToIDFile(shttpFile, idFilehttp);
ObjectUtils objNew;
UIDList objectUIDList = objNew.GetPageItemListNew(document);
UID objectUID = objectUIDList[0];
if (objectUID != kInvalidUID)
{
CAlert::WarningAlert("objectUID != kInvalidUID");
}
Utils<IURIUtils>()->IDFileToURI(idFilehttp,httpURI);
UID resourceUID = kInvalidUID;
PMString formatType("import");
ErrorCode Err1 = Utils<Facade::ILinkFacade>()->CreateResource(db,httpURI,kIDLinkClientID,PMString(),resourceUID);
if (Err1 == kSuccess)
{
CAlert::WarningAlert("Err1 == kSuccess");
}
if (resourceUID != kInvalidUID)
{
CAlert::WarningAlert("resourceUID != kInvalidUID");
}
UID linkUID = kInvalidUID;
ErrorCode Err2 = Utils<Facade::ILinkFacade>()->CreateLink(db,
ILink::kBidirectional,kIDLinkClientID,
objectUID,resourceUID,kFalse,linkUID);
if (Err2 == kSuccess)
{
CAlert::WarningAlert("Err2 == kSuccess");
UIDRef ItemUIDRef(db,objectUID);
InterfacePtr<IHierarchy> iHierarchy(ItemUIDRef,UseDefaultIID());
for(int32 i=iHierarchy->GetChildCount(); i>0; i--)
{
UID iChildUID = iHierarchy->GetChildUID(i);
Utils<Facade::ILinkFacade>()->AttachLink(UIDRef(db,iChildUID), linkUID);
}
}
//Case 1: Tried to place file
InterfacePtr<IGeometry> pageGeometry (parentUIDRef, IID_IGEOMETRY);
if (pageGeometry == nil)
return;
PMRect compareBox = pageGeometry->GetStrokeBoundingBox();
SDKLayoutHelper obj;
UID uidPreview = kInvalidUID;
UIDRef itemRef = obj.PlaceFileInFrame(idFilehttp,parentUIDRef,compareBox,kSuppressUI,kFalse,kFalse,kFalse,uidPreview);
if (itemRef != UIDRef::gNull)
CAlert::WarningAlert("itemRef != UIDRef::gNull");
Let me know if any one can help on this.
Thanks & Regards
Qamar
