Copy link to clipboard
Copied
Hi,
I'm using InDesign to create a memory book. Many people get one page each to fill with content. As past projects have shown, people are really keen about using Emojis, which I'd like to support. But I just can't get Emojis into InDesign via Data Merge, only when I copy&paste them manually.
My workflow so far:
This works. But as for the data merge part:
But the problem is: No matter how I format it and how I convert it, I won't get Emojis into the InDesign document. Only one of the two cases happens:
Does anyone know a solution? What am I overlooking? Is there any other character encoding than UTF16 that InDesign supports?
Ha, I have found a solution!
How to get line breaks and Emojis into InDesign via Data Merge
InDesign doesn't support line breaks or Emojis from data sources that you import via Data Merge. With this workaround, you can encode any special characters in your spreadsheet and decode them in InDesign again.
In your spreadsheet:
Copy link to clipboard
Copied
Ha, I have found a solution!
How to get line breaks and Emojis into InDesign via Data Merge
InDesign doesn't support line breaks or Emojis from data sources that you import via Data Merge. With this workaround, you can encode any special characters in your spreadsheet and decode them in InDesign again.
In your spreadsheet:
In InDesign:
Open a text editor, copy the below script into it, and save it as URL-decode.jsx
Move the script file to your scripts directory - on Windows this is: %AppData%\Adobe\InDesign\Version 14.0\en_GB\Scripts\Scripts Panel
(you can type %AppData% into the Windows search box, press enter and navigate to the folder from there)
URL-decode.jsx:
//DESCRIPTION:Decodes and replaces all URL-encoded strings in the active InDesign document.
//AUTHOR:Johannes Eichberger
//
//Example:
// This%20is%20URL-encoded%20text!
// This is URL-encoded text!
//
//How to use:
// Open an InDesign document with URL-encoded texts.
// Run the script.
// It replaces every (!) text in every text frame.
//
//Limitations:
// Works with text frames that contain text only. Any non-text
// content, such as tables and linked images, will get lost.
// If an encoded text exceeds its container (overset text),
// only the visible part will be replaced. You can run the script
// multiple times to solve this issue.
//
//When to use:
// InDesign's Data Merge has only poor support of character encodings.
// If you want to feed InDesign with Emojis, you can encode them in the
// spreadsheet via =ENCODEURL() and decode them using this script
// after running Data Merge.
//
#target indesign;
function main() {
try {
var myDocument = app.activeDocument;
var myTextFrames = myDocument.textFrames.everyItem();
var myContents = myTextFrames.contents;
for (var i=0; i<myContents.length; i++) {
var thisTextFrame = myDocument.textFrames.item(i);
var myDecoded = decodeURI(myContents[i]);
thisTextFrame.contents = myDecoded;
}
if (i==0) {
throw "No texts found!";
}
alert("Texts have been replaced.");
}
catch(err) {
alert(err);
}
}
main();
Copy link to clipboard
Copied
Hi joheiat ,
FWIW: be aware that your script could change the contents of text frames.
Before, text frame with one anchored object, the yellow rectangle:
After running URL-decode.jsx:
Also a problem. Tables. You'll remove tables.
Before:
After running URL-decode.jsx:
Regards,
Uwe
Copy link to clipboard
Copied
Hi Uwe / Laubender,
Yes, you're right. The script is on a very basic level and only works for text frames which contain nothing else but text. I might think about extending it to keep additional content placed in text frames too. Thanks for pointing me to this!
If anyone has a demand for this, please leave a reply to nudge me.
Also, feel free to extend the script.
Regards,
Johannes
Copy link to clipboard
Copied
Hi Joheiat,
I'm actually in need of exactly this ā a better process for data-merging with emojis. However, when I run your script to decode the url-encoded text, I get an error message. Is the script you posted here accurate and up-to-date? Thanks!
Steven
Copy link to clipboard
Copied
Hi Steven,
So sorry, I happened to see your reply only now. Are you still in the need of this? I tested my script again with the current version of InDesign with a minimalistic test file and it still works. Which error message do you / did you see?
Regards,
Johannes
Copy link to clipboard
Copied
Hi Johannes,
the script code in your correct answer was damaged last year when this thread was moved to the new InDesign forum.
That could be one cause of an error message. Look into the for loop. At first glance I see that the iterator [i] was removed on myContents. Best correct your answer and post the original code again.
Thanks,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hi Uwe,
Thanks for the hint. I've updated my answer.
Best,
Johannes
Copy link to clipboard
Copied
Hello Joheiat,
Since you allready solved the problem how to convert image url to file names: could you share the method/script you used to do so?
Thanks!
Regards,
Pascal
Copy link to clipboard
Copied
Hello Pascal,
Do you mean the Google spreadsheet script that I used to get the file names of images that were uploaded via Google forms? Let me take a look, if I find it I will post it here.
Johannes
Copy link to clipboard
Copied
I'm sorry, I've lost access to the file where I solved this problem. I used a Google Apps script which I had to run manually. If I recall correctly, it did pretty much the same as the one in this StackOverflow answer (check all URLs in one column, and output the file names in another column):
https://stackoverflow.com/a/51398404
Hope this helps you.
Johannes
Copy link to clipboard
Copied
No problem. Thanks for the reply! I will look into it.
Cheers