Of interest: New Data Merge techniques and quote bug

In the latest Colecandoo Youtube episode, four Data Merge specific features are covered, namely:

  • Adding faux-returns to a data merge field to split over lines, and subsequent limitations of this technique;
  • Using GREP styles to swap a character for a glyph during a Data Merge;
  • Highlighting field codes so that they are easier to see when not showing live data; and
  • A bug that occurs when a double-quote is at the start of any field in a Data Merge text file.

Faux returns within a field

The faux-returns technique is written about elsewhere, so rather than spoil their presentations, please read the articles directly from the appropriate sources:

I’m a fan of this trick, but emphasise that this is a workaround rather than a long-term solution, given that formatting is limited and there are more appropriate ways of accomplishing this task such as dedicated plug-ins or an XML workflow.

Swap characters for glyphs

Daniel Solis also features a clever trick to swap phrases with glyphs during a Data Merge that uses both GREP styles and ligatures. Again, rather than simply repeat the technique, please see his original video here.

A similar method can be employed using Indiscripts’ Indyfont script, but rather than swapping phrases with glyphs, will swap single characters.

Highlight Field Codes

The video also shows a method for highlighting field-codes when Data Merge is not in the preview mode. It relies on the [Basic Paragraph] style using a GREP style that contains a large highlight, and that any other styles in the document are based off of the [Basic Paragraph] style. It also means the document has to be styled correctly.

I’d demonstrated this technique following a real-world example of a live file where fields were very hard to see, and the file had to have an offset shell printed with variable data printed afterwards, so making sure the shell had no variable data on it was crucial. Using this technique would make finding the field codes much easier to see.

Double Quote bug

Also featured in the video was an issue that once again arose from a real-world example where a customer had provided a database that had double-quotes at the beginning of fields, but no closing quotes, resulting in rather unusual results.

 

Map GREP styles from one Paragraph Style to another… or many!

There’s no doubt that GREP styles are useful, but hiding the GREP style function within the Paragraph Style dialog box makes applying GREP styles difficult:

  • Previously saved searches made in the find/change dialog box cannot be selected;
  • GREP styles applied to one paragraph style cannot be easily applied to another existing paragraph style

Perhaps a GREP styles panel would be easier. The panel would be like any other panel available in InDesign, and would list the GREP searches by GREP style names (similar to Paragraph and Character styles). Upon double-clicking a GREP style, a dialog box would open and allow the style to be applied to one or many Paragraph styles at once, what Character style the GREP style should apply, and the ability to load previously saved GREP searches from the find/change dialog box (where appropriate).

Great huh? Well, there isn’t one. Perhaps enough people requesting such a panel on Adobe’s wishlist page might persuade the developers at Adobe make one… perhaps fix the footnotes feature at the same time – hint, hint!

Well, until the software developers at Adobe create such a panel, the next best thing is to use workarounds or third party solutions provided in the form of javascripts.

Map GREP styles from one Paragraph Style to one or many Paragraph styles:

A combination of two scripts by separate contributors on the Adobe Forums allowed what I had not thought possible to become possible – select a paragraph style with the desired GREP styles, and then select multiple destination paragraph styles for the GREP styles to be applied. The script can be found here.

Similarly useful GREP style utilities

Peter Kahrel has a page dedicated to his various GREP utilities. Apart from having many GREP tools, his utilities accomplish other GREP style tasks, such as:

  • Ability to map a newly created (or saved search) to one or many paragraph styles with a specific character style.
  • Ability to highlight the results of a GREP search in real time.

Marijan Tompa (aka Tomaxxi) has two GREP scripts, but of interest is TomaxxiGREP. This script presents a panel that shows what GREP styles are applied to highlighted text, and gives real-time ability to change the search code and character style of the GREP style without opening the Paragraph Styles panel.

General GREP assistance

Roland Dreger has a script that highlights the results of a GREP search in real-time in a similar fashion to Peter Kahrel’s GREP editor.

Jongware has a dedicated GREP help page and a script titled “whatthegrep” that takes a GREP search and shows in layman’s terms what is being searched for.

InDesignSecrets website has a dedicated page to providing information about GREP.

Virtuosi Media‘s website provided this gem that contains long GREP chains to find specific items such as date formats or, country postcodes.

 

Variable QR codes? Sort of possible…

splash

UPDATE 2014-07-22: Since the release of Adobe InDesign CC 2014, variable QR codes via Data Merge is now possible. A post will be written about this feature once it has been thoroughly tested, but in the meantime this article has been edited to reflect the update.

Since the invention of QR codes, a burning question has been “how to incorporate these barcodes into a Data Merge?” There are lots of ways to generate one-off QR codes such as:

  • QR code generating websites;
  • An InDesign Javascript written by Jongware that is suitable for CS4-6;
  • Built into InDesign CC and above; and
  • Third party plug-ins that offer one-off creation as a “taster”.

But what if there are 30, 300, 3,000 or 30,000+ codes that need to be made as a direct mail campaign? Creating 30,000 QR codes is not a task that anyone would want to do individually.

So can Adobe InDesign, fresh from the shelf, create a Data Merge with variable QR codes? Apart from the latest release of Adobe InDesign CC 2014, no – not without the use of a third party plug-in. However, this workaround does the next best thing: Creates lots of QR codes all at once, export them as uniquely named PDFs for reference in a Data Merge, and then use the built-in Data Merge feature from InDesign.

The following example is a business card for fictional clothing manufacturer “Mean Jeans”. The client would like QRcodes that feature the staff member’s email address, and if no email address appears then no QR code needs to appear. The client has supplied the database in Microsoft Excel.

There is a way to automate this task thanks to three scripts

  • QRcode.jsxbin by Jongware (as previously mentioned). When this script is used on its own, a user interface appears asking the user for the text to be coded and then a level of error correction. Jongware did allow other scripts to call upon the QRcode script, and that leads into the next script;
  • A slight modification of a script supplied by an Adobe Forums user by the handle of sergemca. The original script (found in the same Adobe Forum link as Jongware’s QRcode.jsxbin) by sergemca searched an open InDesign document for any textboxes that contained the starting words MECARD: and would then convert the contents of the complete textbox into a QR code and then apply formatting such as scaling and rotation. As this example is creating QRcodes from email addresses, the modification in this example searches an open InDesign document for any textboxes that contain the starting word mailto: . Modifications to this script are best dealt with by the scripting forum of the Adobe InDesign forum.
  • PDFStyleExporter.jsxbin by Loic Aigon. This script has featured on Colecandoo before and it is used to split a large InDesign file into single page PDFs with unique names. While researching this story I have noticed that Loic will update this script in due course, so stay tuned.

To create variable QR codes:

  1. Open the Excel file and create two fields in the database in addition to the other fields that need to appear: order, and ‘@QRcode (the ‘ will disappear in Excel after it is typed, this is intentional). In the order column, use the autofill function of Excel to add sequential numbers to this column. Leave the contents of the @QRcode field for now.1qr
  2. Save the Excel file but also save it as a “Windows Formatted Text .txt” file, and give it a name that reflects that this database is purely for the QRcoding only e.g. forcodingonly.txt2qr
  3. In Adobe InDesign, create a new file that will be used to create the QR codes first. In this example, a file that is business card size has been created (90x55mm). Once open, go to the Data Merge panel and select the data source as the recently created txt file. Once the data is available in the Data Merge panel, create two text boxes. One with the word mailto: followed by the <email> field, and another text box with the <order> field. The document should look like this3qr
  4. The order text will provide the filename in a later script, but it also must appear in the file but not get in the way of the QRcode graphic that will appear later. To make sure that this text will be live but not output in the resulting QRcode, select the textbox containing the <order> field, give the text a paragraph style called “order” – the only change is that it has no fill and stroke. Also, align the text box to be in the centre of the page. The document should now look like this4qr
  5. From the Data Merge panel, select “Create Merged Document” and merge to a new single page document.5qr
  6. This will create a large document that will contain one mailto: address per page. It is important at this stage that any mailto: addresses that don’t have email addresses in the text boxes be deleted (or else the QRcode script will make QRcodes that contain the word “mailto:” only and clearly won’t work). To delete these addresses open the Find/Change dialog box and in the GREP panel type in the word mailto:$ , leave the change field blank (as well as the formatting fields) and click Change All.6qr
  7. The document is ready to have the QR codes applied. To do this, the altered version of sergemca’s script needs to be run.
var _d = app.documents[0];
var _allStories = _d.stories;
for(var nx=_allStories.length-1;nx>=0;nx--){
    var _storyAllTextFrames = _allStories[nx].textContainers;
    for(var mx=_storyAllTextFrames.length-1;mx>=0;mx--){
         _storyAllTextFrames[mx].select(); // change page
         if(_storyAllTextFrames[mx].contents.indexOf('mailto:')==0){
             var obj = app.doScript(new File(app.activeScript.path+'/qrcode.jsxbin'), ScriptLanguage.JAVASCRIPT, [_storyAllTextFrames[mx].contents, 3], UndoModes.ENTIRE_SCRIPT);
             _storyAllTextFrames[mx].contents = "";
         };
    };
};

7qr

If done successfully, the InDesign file should now contain QRcodes in place of the text that contained the email addresses.

To export these QRcodes with their unique names

  1. Run the script PDFStyleExporter.jsxbin (called PDFExportCropper.jsxbin on my machine)8qr
  2. In the user interface that appears, select the paragraph style “order” and leave the rest of the dialog box as it is. In the PDF options dropdown field, select the destination to save the resulting PDFs. Once done, click the Export button.9qr

Again, if done successfully, the resulting PDF QR codes should now save to the nominated directory.

There are other ways to export single page PDFs but Loic’s script is used in the example in case a reference other than a sequential number is to be used, such as a person’s name, phone number, etc.

To incorporate these QR codes into the data merge:

  1. Return to the Excel file and in the @QRcode field, use the CONCATENATE function to take the order number and apply the .pdf suffix to it. The formula to use is: =CONCATENATE(A2,”.pdf”)10qr
  2. Save the Excel file and again, also save it as a “Windows Formatted Text .txt” file, and give it a name that reflects that this database has been qrcoded QRcoding only e.g. qrcoded.txt
  3. In Adobe InDesign, create (or open) the card that needs the QRcodes applied. Once ready for the data, go to the Data Merge panel and select the data source as the newly created txt file. Place the name, address references etc as necessary, and create a frame for the QR codes to appear.11qr
  4. Apply the qrcode field to this frame and go to the Data Merge panel and select Content Placement Options. In the dropdown field “Image Placement” select the fitting “Fill frames proportionally”.12qr
  5. Instead of using the “preview” function, go to the Data Merge panel and select the Export to PDF function and export one record only. In the example, page 7 was chosen at random.13qr
  6. Once satisfied that the merge looks like it will work, again use the Export to PDF function to export the entire merge to a PDF.

For the barcodes to fit the image, the PDFs need to import PDFs based on the bounding box. If the images are not fitting the frame properly, an additional script originally by Dave Saunders (but improved upon by Marc Autret) will allow the import option to change. The script is available from this forum and once loaded and run into InDesign, the option to select is “Content All Layers”

14qr

So there it is. It is worth noting that this is a workaround and not a direct live Data Merge solution. There are limitations to this solution:

  • Resulting codes can’t be colorised on-the-fly;
  • If the database changes, this will mean repeating the entire process, rather than simply updating the data in the data merge file once, and removing all  QRcodes created previously.
  • Because the codes are not human readable without a decoder, there is added emphasis to check, recheck and check again to make sure the merge is behaving properly.

While this is a workaround, there is no doubt that a turnkey solution is preferable. There are enough third party providers making variable barcode solutions for Adobe InDesign. The full list is available here. From memory here is a list of third party providers that provide variable QR codes as part of a complete VDP package:

  • Rorohiko’s Tada QR;
  • XMPie’s uDirect;
  • Meadows Publishing Software
  • Cacidi LiveMerge;
  • Teacup Software’s BarcodeMaker;
  • DirectSmile;
  • Objectif Lune’s Printshop Mail;

Several edits since this was first published:

  • Added a list of third party providers who provide variable QR codes and moved a reference to an individual one earlier on in the article into that list;
  • Fixed type within field chevrons that did not appear when the article was published;
  • Acknowledged that variable QR codes via Data Merge are now possible in Adobe InDesign CC 2014

Perform multiple find/change (or GREP) queries at once

The find/change dialog box is a useful tool in InDesign until many searches need to be done at once. For example, an imported word processor file contains double spaces, double returns, spaces at the start of lines etc that need to be tidied. Using solely find/change, each item needs to be found and changed before the next item can be found and changed, meaning typing in the find field, then the change field, then change (or change all). This applies to GREP searches as well.

Ultimately, is there a way to perform many find/changes to text at once? Luckily, the answer is yes, there are several. Will they also change more than the text (such as formatting), not all methods outlined will do this. Some solutions listed below are still in Beta testing, while others may or may not work with Creative Cloud. Links to the providers of each solution has been provided for those seeking more information.

First method – default script (with outside assistance)

There is a script that ships with InDesign called findchangebylist.jsx. This script runs many find/change commands that are stored as text in another file called FindChangeList.txt.

By changing specific lines in the script and making and renaming copies of the FindChangeList.txt file, many different “chained searches” can be made and stored for later use.

Because the code used in the FindChangeList.txt file is rather cody, scripter Kasyan Servetsky has created a script that will take whatever is in the find/change dialog box and turn it into code that can be cut and pasted into the FindChangeList.txt file.

For regular visitors to this site, this article may seem like déjà vu, and that is because this solution has been discussed on Colecandoo before:

https://colecandoo.wordpress.com/2011/08/25/make-findchange-behave-more-like-a-word-macro/

Second method – scripts:

GREP Queries Manager by Peter Kahrel

Unlike the first method, this has a user interface and deals with GREP searches rather than both GREP and find/change searches.

For full details on how it works, go to: http://www.kahrel.plus.com/indesign/grep_query_manager.html

Doquery by Mikhail Ivanyushin

Again, this has a user interface and can use find/changes or GREP searches that have been previously used and saved with the find/change dialog box.

For full details on how it works, go to: http://adobeindesign.ru/2012/10/27/doquerylist-programma-obrabotki-teksta-zaprosami/

Batch find and replace by Fabiantheblind

This solution does not have a user interface but rather works in a similar fashion to InDesign’s default script but uses Fabian’s own expression language.

For full details on how it works, go to: https://github.com/fabiantheblind/batch-find-and-replace

Kerntiff’s Xchange

This solution has a user interface and can perform many find/changes at once, whether regular find/change or GREP.

For full details on how it works, go to: http://www.kerntiff.co.uk/free-stuff/xchange-strings-xstrings

Third method – plug-ins

Automatication

This plug-in has a user interface and what the find/change dialog box in InDesign should really have shipped by default. Nevertheless it is cheaper than a slab of beer and will last much much longer.

For full details on how it works, go to: http://automatication.com/

Action Recorder (Rorohiko)

While still in the Beta stage, Rorohiko is attempting to make what is arguably missing from the InDesign menu: the Actions palette.  Other than running find/change commands, this extension allows much more chaining and automation of other non-text based tasks, but at the time of writing is still too early to tell.

For full details on how to become involved, go to: http://www.rorohiko.com/wordpress/2013/08/06/action-recorder-beta-released/

 

%d bloggers like this: