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

Multiple record data merge into paragraph styles-applies the wrong style

New Here ,
Nov 22, 2013 Nov 22, 2013

Copy link to clipboard

Copied

Hi, I've been working on this project for sometime and everytime I manage to get one part of the workflow to work another seems to break. My agency publishes catalogs in multiple formats: large-print, audio, braille, and HTML. I've been trying to redesing our work process so that the catalogs will be laid out from merged data out of comma-separated file. The data merges have worked fairly well in Word, but InDesign is a challenge. I'm merging multiple records on a page, like a mailing label. The paragraphs need to be formatted and I'm trying to apply a paragraph style to them. After much work, I think I've finally got the data merge to work correctly, but the wrong paragraph styles are applied. I'm going to apply a new master page to the data once the data is merge that uses the paragraph styles for text variable running headers and I need to build a table of contents based on the paragraph styles so I need this to work. Attached are some screenshots.

Master page set up for data merge with paragraph styles:

datamerge master page.gif

Here is the merged document with the wrong paragraph styles applied:

Merged document has wrong paragraph styles applied.gif

I have only a few weeks to get this process ironed out to keep to our rigorous production schedule. If anyone can help I would really appreciate it.

thanks,

Lina

Views

34.1K

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
replies 185 Replies 185
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

Uwe,

I'm gong to test this tomorrow on my directory job (which I've stitched manually up to now because I'm too lazy to install the Rorohiko script). It should knock about half an hour off the time I spend.

I think I've alread got a return at the end of the last line in each record, though, in my template (I could get rid of it easily, though). Can this be edited easily to not add another?

I'm not an expert at reading javascript, but it looks to me like you are adding two returns at the start of each text frame.

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
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

@Peter – you are right. I'm adding TWO returns.

The reason is:
I assume that there is NO return at the end of each text frame and I want to add an empty separator paragraph between the texts of each text frames.

I would NOT recommend leaving a single return at the end of each text frame…

It's much cleaner to go without one and have a dedicated empty paragraph with a dedicated paragraph style for separating the contents of each text frame after running the script.

Be forwarned: depending of the number of text frames, the script takes its time.

About two minutes in the case of the material you provided (564 text frames on 141 pages in a 2x2 matrix for each page) on a five years old MacBook Pro with InDesign CS5.5 and OSX 10.6.8 installed.


Uwe

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
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

I'm curious why you want the empty paragraph? We normally preach aginst using empty paragraphs instead of adding space before/after to one of the styles. In fact, that's the way my directory merge is set up. The name style that starts each listing has space before included, and the business description that ends each listing has a return at the end (I normally don't have a return as the last character in a story), so as I manually thread frames from back to front it's just two clicks and the spacing is built in.

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
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

The point is:

I would not recommend to take "Adding Space Before/After" in the case of Lina's data to separate each unit from the other. In Lina's case it could be any of her paragraphs styles, that a new unit will begin with.

Provided: the last section of each text frame is ALWAYS EXACTLY one paragraph long AND ALWAYS styled with the same paragraph style.

So I decided that best flexibility will provided with an empty paragraph. You can style this one as you like. Or eliminate it with a quick TEXT search/replace action…

Uwe

Message was edited by: Laubender

Message was edited by: Laubender

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
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

OK, yes, I see your point. I was thinking of my case and forgetting that Lina has records with null fileds at the start (all mine are later). I suspect it would work, though, to add space after to the annotation style unless there are also records with no annotations.

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
Valorous Hero ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

Thanks, Uwe!

@Peter, you can always edit the script. I have for the double return (don't need 'em). I commented out the necessary lines for the just in case, one day I'll need them scenario.

Again, Uwe, thank you for all your efforts.

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
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

Hi Mike,

Yes I was planning to do that too, just wanted to verify which lines. I think it's all 5 lines after the first IF statement.

What did you comment out?

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
Valorous Hero ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

The 4 lines in the screen shot, leave the middle var line

capture-000801.png

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
Community Expert ,
Dec 05, 2013 Dec 05, 2013

Copy link to clipboard

Copied

You don't need the variable either, as far as I can tell, since it looks like the only place it's used is the next two lines you commented out (which remove the extra returns in front of the first record).

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
Community Expert ,
Dec 06, 2013 Dec 06, 2013

Copy link to clipboard

Copied

@Peter Chater and Mike – here the version of the script WITHOUT including an empty paragraph between the units:

(Just to end the debate what should be commented out and what not 😉 )

 

//NOT-INCLUDING-EMPTY-PARAGRAPH_StitchTextFramesAfterDatamerge_IN-CREATION-ORDER.jsx
//Uwe Laubender

//DESCRIPTION:Does NOT work, if some text frames are already stitched (threaded) together!!

/**
* @@@BUILDINFO@@@ NOT-INCLUDING-EMPTY-PARAGRAPH_StitchTextFramesAfterDatamerge_IN-CREATION-ORDER.jsx !Version! Fri Dec 06 2013 10:21:05 GMT+0100
*/


app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

try{
app.doScript(_StitchTextFramesWithoutParagraphInsertion, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Stitch text frames without paragraph insertion together: page by page.");
}catch(e){alert("Sorry, something went wrong:"+"\t"+e.message);exit(0)};

alert("DONE! Text frames on pages (not on the pasteboard) are threaded page by page in creation order!");

function _StitchTextFramesWithoutParagraphInsertion(){

var d=app.documents[0];

d.textFrames.everyItem().insertionPoints[0].contents = "\r";

var firstTextFrameID = threadTextFramesInBuildingOrderPageByPage(app.documents[0]);

d.textFrames.itemByID(firstTextFrameID).characters[0].remove();

//FUNCTION
//Returns ID number of first built text frame by lowest number !!

function threadTextFramesInBuildingOrderPageByPage(myDoc){
    
    var d=myDoc;
    var myPages = d.pages;
    var IDArrayByPages = new Array();
    var n, m, currentTF, nextTF;
    
    for(n=0;n<myPages.length;n++){
        if(myPages[n].textFrames.length >0){
            
            IDArrayByPages = IDArrayByPages.concat(myPages[n].textFrames.everyItem().id.sort());
            
            };
        };
    
    //Stitch together:
    for(m=0;m<IDArrayByPages.length-1;m++){
        
        currentTF = d.textFrames.itemByID(IDArrayByPages[m]);
        nextTF = d.textFrames.itemByID(IDArrayByPages[m+1]);
        
        currentTF.nextTextFrame = nextTF;
        };
    
    return IDArrayByPages[0];
    };

}; //END function _StitchTextFramesWithoutParagraphInsertion(){}

 

NOTE:

Recreated the code above, because it was damaged when this thread was moved to the new InDesign User Forum in October or November 2019.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

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
Community Expert ,
Dec 06, 2013 Dec 06, 2013

Copy link to clipboard

Copied

Thank you, and sorry to have started such a ruckus.

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
Valorous Hero ,
Dec 06, 2013 Dec 06, 2013

Copy link to clipboard

Copied

No ruckus, no debate a happenin'

Once again, this has been one of the best working threads I have been a part of. Thanks to all...and a special thanks to Uwe.

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
Community Expert ,
Dec 06, 2013 Dec 06, 2013

Copy link to clipboard

Copied

Very much so. What we've managed to learn here has legs.

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 ,
Dec 06, 2013 Dec 06, 2013

Copy link to clipboard

Copied

Really the script was exactly what I was looking for and I finally got adminstrative permission to run it. Below is an image of your well-functioning, helpful script. I remain in your debt.

Lina

Document after running Uwe's Stitch together script:

Stitch together script.gif

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
Community Expert ,
Dec 08, 2013 Dec 08, 2013

Copy link to clipboard

Copied

@Lina – so: all well and done?

Peter and I had a small discussion about using or not using a separator paragraph between the units. If you find it not useful, just run the other script to stitch the text frames together right after the TEXT and GREP search/replace actions when none of the text frames are threaded to one story.

Or have a GREP search/replace for empty paragraphs again.

Ok. I think we can close this issue now. But before doing so, you could mark some of the answers as "Helpful" and one answer as "Correct". Of course it's up to you…

Here a summary of all the steps:

0. Not discussed here, but for the usage of foreign languages it might be a good idea to save the CSV or TEXT files that hold the base data for the merge as Unicode UTF-16. Especially if you are placing images with datamerge that include special characters like umlauts (äöü) etc.pp.

1. Do the merge. DO NOT remove blank lines during the merge!

2. If XML tags after data merge show up, you must get rid of them, if you want do a TEXT or GREP search/replace for empty paragraphs. It's easy by script (see answer #81)

http://forums.adobe.com/message/5894351#5894351

(We still don't know the cause for XML tags after a datamerge!)

3. Do a TEXT search/replace to get rid of the special characters.

Search for (without the quotes): "<FEFF>"

Replace with nothing (= will delete all the special characters, that will prevent the next step!)

4. Do a GREP search/replace to get rid of empty paragraphs (if that is what you really want!)

Search for (without the quotes): "^\s+"

Replace with nothing

Or use a script combining steps 3 and 4 (see answer #58):

http://forums.adobe.com/message/5883785#5883785

Optional:

5. Two scripts for stitching text frames together.
Check the results thoroughly! Are the right text frames stitched in the right order?

5.1 One script that includes a separator paragraph between the units (see answer #108):

http://forums.adobe.com/message/5904790#5904790

5.2 One that does NOT include a separator paragraph (see answer #119):

http://forums.adobe.com/message/5906160#5906160

Or use a different script to do that. There are some around, commercial or not…

Uwe

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 ,
Dec 09, 2013 Dec 09, 2013

Copy link to clipboard

Copied

Uwe,

Yes the paragraph separator works for me. I have saved my CSV as UTF code,

note sure that UTF-16 is one of my options, but have saved it as UTF

because of the large number of foreign vowels and diacritical marks. And so

far, so good everything seems to be working. I am deeply indebted to you

for all of your good work.

Lina

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 ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

Sorry, I must be doing something wrong now. I've followed the process to the "T", but when I get to the stitch together script, the text boxes merge over one another like this:

Step11Errorovermergedscript.gif

Here's a reprieve of everything we figured out, step-by-step:

Step 1 Opened up the document merge template I set up and changed the CSV file:

Step1changeCSVfile.gif

Step 2 Created new data merge document:

Step2createnewmergefile.gif

Step 3 Included blank lines:

Step3includeblanklines.gif

Step 4: Merged Document:

Step4datamergecompleted.gif

Step 5 ran your remove XML tag script:

Step5RunXMLtagremovalscript.gif

Step 5: Document no xml tags:

Step6XMLtagsremoved.gif

Step 7 Ran the text search:

Step7Runtextsearch.gif

Step 8 Ran the GREP Search:

Step8RunGREPsearch.gif

Step 9 Here's the Document without extra tags:

Step9Documentwithoutextratags.gif

Step 10 Then I run the stitch together script:

Step10Runstitchscript.gif

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
Community Expert ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard

Copied

Hi Lina,

I just tried the scrip on the first 25 records of your data file here and got some stagnge results, too -- the thread is non-linear, though I don't have any superimposed frames. The text is threaded correctly for me, though, as far as I can tell.

Try doing a select all for the text, then copy and paste into a new document and see if it looks correct.

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

@Lina & Peter – ok, then my script will fail, because my assumptions  made upon ID numbers on text frames built by data merge seems wrong.

Back to testing then and do a more reliable algorithm based on geometrics then…

@Peter – Did you do your tests on the same material you sent me?

Uwe

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

Yes, I did.

Not sure if I was really clear about what happened, though. The order of the text was correct after the merge, as far as I could tell, but the order of frames had been shuffled on at least the first page, which ended up looking like a mass of knotted spaghetti when I turned on the text thread view.

There doesn't seem to be an obvious repeatable pattern to the shuffling, either. Just did two more tests, one with 35 records and it shuffled pages 1 and 5 of 9, and another with all records and it did only page 5 in the first 50 0f 188 (didn't continue checking). Doesn't matter, either if the merge fileds, etc, are removed first.

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

@Peter – ok. Then it seems data merge is rather "jumpy" in creation of the text frames (= not in geometrical order). That means, one would fair better using the stitching method by the Rorohico script.

http://www.rorohiko.com/wordpress/indesign-downloads/textstitch/http://

Or I'll do another attempt based on geometrical positions of text frames on a page.

Uwe

Message was edited by: Laubender

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

As I said, the text itself seems to be threaded in the correct order, so it can be moved to a new file via copy/paste and it flows properly. It behaves as if the bounds for pairs of frames are randomly switched.

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

@Peter – Aha ?! Well…

Amazing.
You could send me an IDML of that result.

Uwe

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

On its way.

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
Community Expert ,
Dec 21, 2013 Dec 21, 2013

Copy link to clipboard

Copied

@Peter – thank you for sharing…


So, in this case, stitching together the text frames in geometrical order would result in the wrong order of texts. Wow.

I'll try a few experiments with data source you provided the last time…


And will analyze the IDs of every text frame on every page anew. Something very strange is going on here with data merge. And I think it has nothing to do with scripting or TEXT search/replace or GREP search/replace beforehand or after.

At least  it seems, I got the right approach with my script stitching text frames together.

The order of texts will be the right one.


Uwe

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