I am facing problem in inserting Xref in the document that Xref is linked to the Figure in different document. I am not getting the logic how this can be established using Extend Script. Please guide me how this can be done. If possible, please share the example Script.
Thanks & Regards,
I don't have code to do this, but can give an an outline of what I believe is required, This is untested and might be incomplete:
I'm sorry, but I don't have the bendwidth rght now to give further help.
Thanks you very much Mike for providing complete logic.
I will work on that to get the results .
Thanks & Regards,
Mike's summary is pretty good. Here is some almost-complete sample code that inserts an unstructured xref to a different file. The xref is inserted at the current insertion point in the source doc, and targets the paragraph with the insertion point in the target doc. This may not be exactly how you want to locate the new items but it is the simplest way to demonstrate how its done.
var sourceDoc =
/* some code to get the doc in which to insert the xref */
var targetDoc =
/* some code to get the doc that the xref will target */
//Insert a new marker object at the current insertion point
var marker = targetDoc.NewAnchoredMarker(targetDoc.TextSelection.beg);
//Make it a Cross-Ref marker, required for xrefs to target
marker.MarkerTypeId = targetDoc.GetNamedMarkerType ("Cross-Ref");
//Add some marker text. This needs to be unique among all
//Cross-Ref markers in the doc
marker.MarkerText = "xref_target_id";
//Insert a new xref object at the current insertion point in the source doc.
//Note that "Para_Text" is the xref format... you would need to use a format
//from your template.
var xref = sourceDoc.NewAnchoredFormattedXRef("Para_Text", sourceDoc.TextSelection.beg);
//Set the properties required to make it an unstructured xref to the
//new marker in the other doc.
xref.XRefSrcIsElem = false;
xref.XRefFile = targetDoc.Name;
xref.XRefSrcText = marker.MarkerText;
//Update the new xref.