Use the NewAnchoredFormattedXRef method instead. It works in my script (which creates XRefs for structured FM documents).
First of all let me thank you for all your documentation regarding ES and Framescript, I have learn a lot with all your tips.
How can I connect or link the Cross-Ref Marker to the Xref? Using the XRefSrcText property perhaps? And also, do I need to use the string with unique ID:pgf_tag:text or just the pgf text that contains the marker.
May I ask you to publish the code for this method?
Not right now. The code I have is for structured FM documents and would need some changes to make it work for unstructured documents, and I am on holiday in the Dutch Carribean. Possibly next week, if I remember to do it. There are a couple of things you need to figure out about the XRefs in FM. If you cannot wait until next week, use this method to learn about XRefs:
1. Create an XRef using FM's own method
2. Select the XRef in your document
3. Create a script that allows you to investigate the oDoc.TextSelection that contains the XRef marker - use the Data Browser in the ESTK for this.
4. Make small changes to the XRef marker from your test script and see what happens to the XRef in FM
Hi again Jang:
I have been trying to create the XREF following your suggestions:
- First I created a XREF using the FM procedure. Then I created a code to get the info from Data Browser in the ESTK.
- Then I created a XREF using my own code: FM recognizes the XREF (as you can see on the right image) but I cannot get any cross-ref on the content.
Here is the code for the Cross-ref marker target creation:
var doc = app.ActiveDoc; var flow = doc.MainFlowInDoc; var pgf = doc.TextSelection.beg.obj var tLoc, marker, markerType; tLoc = new TextLoc(pgf, 0); marker = doc.NewAnchoredObject(Constants.FO_Marker, tLoc); markerType = doc.GetNamedObject(Constants.FO_MarkerType, "Cross-Ref"); marker.MarkerTypeId = markerType; marker.MarkerText = "10978: Heading1: PREAMBLE";
Here is the code I am using to create the XREF:
var doc = app.ActiveDoc; var flow = doc.MainFlowInDoc; var pgf = doc.TextSelection.beg.obj; var oTLoc1=new TextLoc (pgf, 0); var format="Page"; var newcrossref=doc.NewAnchoredFormattedXRef(format, oTLoc1); newcrossref.XRefFmt.Name=format; newcrossref.XRefSrcText= "10978: Heading1: PREAMBLE";
I have tried with tons of modifications but without success.
I hope you can help me!
Your code does work, but you forgot to update the cross-references in your document. To do this in the code, add the following line to the end of the XRef insertion code snippet:
doc.UpdateXRef ( doc, newcrossref );
Thanks a lot Jang!!!!
Yes it works with all cross-references in the same document. If you create cross-references to others files you will need to specify the XRefFile parameter and use the UpdateXRefs method instead of UpdateXRef.
Again, thanks for your help