2

I have an InDesign document with a data source (csv). Part of the template looks like this:

<<first-title>><<first-text>><<second-title>><<second-text>><<third-title>><<third-text>>

The reason it is all on one line is because a variable can be empty and I don't want it to create empty lines.

The texts (<<first-text>>, <<second-text>> and <<third-text>>) should contain newlines, but that is not possible with csv data merge. I did find a solution with a character style and a paragraph style to mimic a newline (https://indesignsecrets.com/controlling-line-breaks-with-data-merge.php) but that just introduces some whitespace for me, no newlines.

So I thought, I'll just make a script to replace some string (I chose _LB_) with a linebreak (\n). That works when I put that string (_LB_) in the text and then run the script, it is replaced with a newline. But that does'nt work with data merge, since you cannot (or I can't find how) run a script automatically for each data entry?

Is there another, better solution for this you may know of?

2 Answers 2

1

You can just add new lines for each entry, then run a basic Grep query to remove empty paragraphs: https://indesignsecrets.com/topic/quick-way-to-remove-blank-lines

5
  • Well, yes, except that I don't think that works with data merge because you cannot (again, maybe I just don't know how) do a find-replace on all content after the data merge (so with the actual generated content for all rows) Feb 26, 2019 at 8:29
  • Why not? You import the stuff via Data Merge, then Create Merged Document, which turns your document into a normal document, then you can GREP freely as with any normal document.
    – Lucian
    Feb 26, 2019 at 8:31
  • Hmyes, that does work indeed! It is a bit more work when previewing the merge, but that's ok I guess. Thanks! Feb 26, 2019 at 8:44
  • The answer was edited, to be complete, the full solution is to just generate the document (skipping empty lines) including the _LB_'s and do a grep replace afterwards Feb 26, 2019 at 8:53
  • Using professional software will do that for you - it's all the small issues that make each data merge job a pain. But if you earn money with that - time is a factor. Checkout MyDataMerge if you're on Mac. It saves tons of time, is the most easiest to use merge software we found and handles cases like that with ease (additionally you could merge into single files named from your database)
    – Pat_Morita
    Mar 21, 2019 at 23:35
0

Is there a reason "Remove blank lines for empty fields" in placement options doesn't work for you? Just put the return in your layout and it will remove the return if fields are empty.

Be aware that any static characters within the line will preserve the line break, so be sure any needed spaces are in the data. Also be aware that because it removes the return, all lines should have the same formatting. Otherwise, a suppressed line will pick up the formatting from above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.