• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Merging multiple documents into one, but losing cross-references

New Here ,
Mar 19, 2017 Mar 19, 2017

Copy link to clipboard

Copied

Hi,

I'm trying to merge several INDD documents into one editable INDD document. Moving pages is easy, with the Page panel and Move order.
However, the cross-references for cross-documents go haywire after I move it, losing destinations and such.

Is there a way (or a script) that could merge all documents into one and update the cross-references for the new (single) document?
I'm losing several of hours of worktime since we have to manually adjust it.

Any help would be greatly appreciated.

Thank you.

Views

977

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Mar 20, 2017 Mar 20, 2017

First of all, let’s look under the hood to see what happens when we make cross-references in InDesign.

Here I posted the sample files and scripts used in the testing described below.

I created a new document Test-1.indd and added three anchor points using the default names offered by InDesign: Anchor 1, Anchor 2 and Anchor 3. Then I created three cross-references pointing to them.

20-03-2017 18-08-40.png

Finally, I duplicated resaved the file as Test-2.indd

From the scripting point of view, cross-reference (which we see in

...

Votes

Translate

Translate
Community Expert ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

Hi,

have you considered creating a book instead of merging the pages?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 21, 2017 Mar 21, 2017

Copy link to clipboard

Copied

It originally is a book, but needs to be merged for other purposes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

Yes. it's possible to solve this issue by scripting. I just wrote a couple of scripts. Going to post them here with explanation and sample files.

— Kas

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

First of all, let’s look under the hood to see what happens when we make cross-references in InDesign.

Here I posted the sample files and scripts used in the testing described below.

I created a new document Test-1.indd and added three anchor points using the default names offered by InDesign: Anchor 1, Anchor 2 and Anchor 3. Then I created three cross-references pointing to them.

20-03-2017 18-08-40.png

Finally, I duplicated resaved the file as Test-2.indd

From the scripting point of view, cross-reference (which we see in the cross-references panel) is a variety of the hyperlink object. Hyperlink contains two other objects: destination and source. All the three have names which are generated by InDesign.

20-03-2017 13-17-34.png

Let’s open Test-1.indd and run this script. (List hyperlink names.jsx)

Main();

function Main() {

    var hyperlink,

    str ="",

    doc = app.activeDocument,

    hyperlinks = doc.hyperlinks;

   

    for (var i = 0; i < hyperlinks.length; i++) {

        hyperlink = hyperlinks;

        str += "#" + (i + 1) + " - Hyperlink: " + hyperlink.name + ", destination: " + hyperlink.destination.name + ", source: " + hyperlink.source.name + "\r";

    }

    alert(str);

}

We see that InDesign uses some default base names adding incrementing numbers at the end.

20-03-2017 18-39-28.png

Now let’s cut the text frame from Test-1.indd, paste it into Test-2.indd (note it has six cross-references now) and run the script again.

20-03-2017 18-47-53.png

Note that InDesign automatically resolved the conflict – both documents had the same set of cross-references using exactly the same names – by adding next available order numbers.

Here’s the root of the problem: when we move text/pages to another document, cut/copy-paste text, rename files, etc. the names can be changed and in turn destinations can be lost.

My idea of solving it is as follows:

Before making any manipulations, which can break cross-references – e.g. moving pages to another document – we run a script which generates a unique name (13-14 digits) and renames each cross-reference (in scripting terms: hyperlink, destination and source).

When cross-references get broken, we open all the documents and run another script which loops through them fixing broken cross-references which it finds by unique names.

Let’s illustrate this with an example:

I created a test file -- Starting Point.indd -- with 15 cross-references. Note the default names

20-03-2017 19-16-09.png

Now I run the Rename cross-references script: all names are unique numbers (Renamed xRefs.indd)

20-03-2017 19-03-41.png

Now I move each page to another document and open them all, all cross-references are OK (green circle) so far.

20-03-2017 19-17-05.png

But if I close and rename the files, or move them to other folders, they become corrupted.

20-03-2017 19-16-35.png

Finally, I run the Fix cross-references script and all the cross-references become normal again.

Of course, this doesn't handle a situation when a few cross-references point to the same destination, but this also can be handled by script: off the top of my head: the first script may create a txt/csv file listing the pairs cross-reference—destination, the second one may read it to restore broken cross-references.

Regards,
Kas

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 21, 2017 Mar 21, 2017

Copy link to clipboard

Copied

First of all, thank you for posting with such kindness. I'll try the scripts you've shared, and hope for the best.

I'll come back with the results. Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 21, 2017 Mar 21, 2017

Copy link to clipboard

Copied

LATEST

However I can't promise it will work for you since I haven't seen your files and have no idea what settings you use for creating your cross-references and what happens to them after data merge.

— Kas

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines