2 Replies Latest reply on Dec 30, 2010 11:39 PM by thomas rollins

    how to link a value in a cell to a page number?

    thomas rollins

      I have a series of diagrams that I'd like to create a table for showing the page it's on, and a description of it. during creation, i an simply store the value of the page number in an array, and use it when creating the table, however, if the diagram is moved onto another page, then the cell shows the wrong page number, and the table loses meaning. Is there a way I can link the page number shown in the table cell with that of the page number it's currently on?

        • 1. Re: how to link a value in a cell to a page number?
          Kasyan Servetsky Level 5

          If you are on CS4/5, you can use crossreference feature to get dynamic page numbers. The diagram is an image, isn't it? You can add a text frame to the graphic frame containing the image (use the same geometric bounds to make both frames the same size; no stroke, no fill -- btw you can do this only by script, not interactively in InDesign) and add a hyperlinkTextDestination to it. Thus when diagrams move, you'll have to just update crossreferences.

           

          Kasyan

          • 2. Re: how to link a value in a cell to a page number?
            thomas rollins Level 1

            Excellent thank you. While I was creating this sample code, I kept seeing an undefined destination text with either PB or OV shown in the cross references. This was because the textframe inside the frame that contains the image wasn't set to the same geometricBoundaries as the container frame!

             

            #target indesign

             

            var doc = app.documents.add();

             

            // add new page with image
            var page = doc.pages.add();
            var imageGraphic = page.place(File('image.jpg'));
            var imageFrame = imageGraphic[0].parent;
            imageFrame.geometricBounds = [0,0,100,100];
            imageFrame.fit(FitOptions.fillProportionally);

             

            // add text frame to imageframe for hyperlink dest
            var tf = imageFrame.textFrames.add();
            tf.contents = " ";    // insert blank text
            tf.geometricBounds = [0,0,100,100];     // THIS IS VITAL otherwise the destination becomes invalid for some reason
            var destination = tf.paragraphs.item(0);    // find text / char destination
            var destination = doc.hyperlinkTextDestinations.add(destination, {name:"foo"});    // hyperlinktextdestination reference 

             

            var creditPage = doc.pages.add();
            var creditPageTF = creditPage.textFrames.add();
            creditPageTF.geometricBounds = [0,300, 100, 400];
            creditPageTF.contents = "...";

             

            var xRefForm = doc.crossReferenceFormats.item("Page Number");   // Default CS5 xref format that shows "Page 45" etc
            var sourceText = creditPageTF.paragraphs.item(0);

             

            var source = doc.crossReferenceSources.add(sourceText, xRefForm);
            var destination = doc.hyperlinkTextDestinations.item("foo");     // find text anchor by name from above
            var myLink = doc.hyperlinks.add(source, destination);

             

            myLink.visible = false;

             

            very confusingly, there seems to be two types of cross references for cs5, cross references for text, which are actually hyperlinks, and crossreferences for tocs i believe (which I know nothing about atm!)