Advertisements

Data Merge to Single Records Pro: Now Available

Since 2016, Colecandoo has provided the free version of the Data Merge to Single Records script for Adobe InDesign – a script that allows single records to be exported from Data Merge with unique filenames available from the Data Merge database itself. This improves Adobe InDesign’s default – naming each file Untitled-N and is only available for InDesign files, not PDFs.

On that note, the PRO version of this script is now available!

This script improves upon the free original by:

  • Exporting to various additional file formats, such as interactive PDF, EPS, PNG, JPG, direct to print, or PDF via InDesign first;
  • Add a primary key to either the start or the end of a filename;
  • When exporting to certain file formats – the ability to run a user-selected additional script before the export.

The script can be purchased for A$15 from the Buy Now button below.


The original Data Merge to Single Records script offered by Colecandoo remains free and can be downloaded from the scripts page.

Advertisements

GREPgraphing – Beyond 2000

In 2016, I developed a concept of creating bar graphs using GREP styles. Put simply, when a number was typed such as 1423, several different GREP styles would kick in to transform the number into a bar graph. In the above example:

  • if there’s a one for the 1 followed by three digits, make the one character 1000% wide;
  • If there’s a 4 followed by two digits, make the four character 400% wide;
  • If there’s a 2 followed by one digit, make the two character 20% wide;
  • If there’s a 3 as the last character, make the three 3% wide.

To successfully work with any whole number between 1-1999, this technique requires creating 29 different types of GREP styles and character styles. It uses a fixed width font and takes advantage of GREP styles to adjust the width of the numbers to represent them as their appropriate value as a bar graph. I’ve written about this technique in more detail over at InDesignSecrets.

In 2018, I expanded upon this idea and made a script so that anyone wishing to use the technique without typing the 29 character and GREP styles could simply run a script:

Beyond 2000

One catch with this technique is that it stops at 1999 as the character style to represent 2000 can’t be made by creating a 2000% width as the maximum character width is 1000%. However, there is a workaround – create a new character style called 2000, based on the 1000 style, but give it a tracking of 600.

Adjust the GREP graph paragraph style and underneath the 1000% GREPstyle, make a new one using the new 2000% character style that was made and give it the following pattern:

2(?=\d\d\d\b)

To test this, I have two different GREPgraph styles containing the 1000 figure and have put them side by side. In the text frame underneath, if I type 2000 into the text frame with the GREPgraph beyond 2000 style applied to it, it should be the same width, right?

Absolutely. If I make an additional 3000% character style based on the 2000% style but changed its tracking to 1200, and added a GREPstyle to the paragraph style to apply the 3000% character style to the pattern 3(?=\d\d\d\b), this will work too.

From here, a pattern can now be seen: to get to the next 1000 in width, add another 600 to the tracking of that thousand’s character style and add a new GREP style pattern to the GREPgraph style. This will work until the tracking hits its maximum of 10,000.

Doing all this in less GREP steps

As stated earlier, the original technique required 29 GREP styles to create a GREPgraph, but what if I said it was possible to achieve the numbers 1-1999 (actually a few more – 2047) using 12 GREP styles? This can be done too, but requires a technique in Excel, and that is to convert the original base-10 number into a 16-bit binary number. I’d actually described this technique back in 2011, but it was implemented differently and with more complications: this method is far simpler.

First, convert the desired base-10 number to a 16-bit binary number in Excel using the following formula:

=DEC2BIN(A1/256,8)&DEC2BIN(MOD(A1,256),8)

Now that the number is displayed in binary, copy the binary number into InDesign.

The technique basically works the same way as the original GREPgraph technique but has a slightly different implementation. First, the character styles need to be created that will change the widths, but instead of making 1-9, 10-90, 100-900 and 1000, only the character styles 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 and 1024 need to be created. For example, the character style 32 will only contain the width of 32%, and this pattern will apply to the other numbers mentioned.

Zero and 1024 are the exceptions. Zero will have a character style featuring a .1pt size, no fill or stroke, and 1% width. 1024 will have a character style of 1000% and a tracking of 14.

This will create a total of 12 character styles.

Now to make the paragraph style. To keep it simple, the appearance of the bar graph will controlled by the paragraph rule (though more advanced methods can be made using combinations of rule above, below, underlines and strikethroughs).

Here is where the magic happens – the GREP styles. Here are the styles and how they are implemented in the GREP style panel of the Paragraph style.

And here is the result:

So what’s happening here?

It’s important to understand how binary numbers are written compared to base-10 numbers. The following site gives a really good explanation, and that’s all that’s happening here – the GREP styles are being applied to the 1s in the binary number, based on their position in the binary number, and applying the appropriate GREP widths.

It can go larger

Just like the regular GREP graph, this too can be expanded to numbers larger than 2000 by creating an additional character style that has an added tracking applied. In this case, to represent the numbers 1-4095, a further character style can be added: 2048.

An advantage of this technique is that instead of creating an additional 9 character/GREP styles for each power of 10 using the base-10 GREP styles, the binary method will require a new style every time the total doubles e.g. 14th GREP style would be 4096, 15th GREP style would be 8192…

The obvious disadvantage with this technique: the numbers to be displayed as bar graphs have to be written out in binary first.

Is this something I would use? Probably not myself, as GREPgraphs are normally enough for my purposes, but I often hear the question “what if you need more than 1999 in a graph” so I felt that it was worth answering the question: It can be done, but it’s a lot of effort to get there.

Please fix Text Variables so they behave like regular text

Within the type menu of Adobe InDesign is the Text Variables feature. This allows users to insert a special character that will display one of the following items:

  • A chapter number
  • A file-related date such as the creation date, modification date or output date
  • Filename
  • Image Name (aka captions setup)
  • Last Page Number
  • Running Header based on either a used paragraph or character style
  • Custom static text

Unfortunately, there is an unwanted behaviour of the text variables – InDesign treats them as a single character rather than the actual content within the variable. This has a few unwanted consequences:

  • Long variables that would normally break over several lines are squished into one line;
  • They cannot be formatted using GREP or Nested styles, nor can specific words be manually selected for formatting.

It’s an issue that is “in backlog” by the Adobe InDesign team to address, but that was first stated in 2017.

If the issue was resolved, it would have enabled my GREPGraph solution to be applied in the following InDesignSecrets article.

As it turns out, it is also affecting another solution that would make lives easier for anyone who has to create diaries and planners on a regular basis.

The brief:

A planner is created by making a base template and then creating threaded text for the dates that are represented only by numbers. This makes populating a diary from week to week relatively easy…

…until the other material has to be populated, such as what month it is, what term it is, and what week it is. This is best illustrated in the first two minutes of a Youtube video by Rob Cubbon.

Incidentally in Rob’s video, he uses frame breaks between each record, but that isn’t required. Instead, adjust the paragraph style of the numbers by going to the Keep Options and from the Start Paragraph dropdown, select In Next Frame.

The technique:

Instead of populating the text frames simply with numbers, what if the frames were populated with more information that can be called upon by running header text variables, such as the month?

I can make a list in excel that contains the day of the week and the month in one column. This is also done without a space intentionally for reasons that will become evident soon.

I can then copy this text to my InDesign file. However, note that the text overflows and isn’t correct – that is because the flowing numbers need to have a character style that will hide the text that we want to be visible elsewhere. To do this, I’ve created a character style called hidden, and its properties are:

  • .1 point high;
  • 1% wide;
  • No fill or stroke.

That’s fine, but applying that manually to everything but the numbers will be a nuisance, so the paragraph style for the numbers has to be modified using Nested Styles.

The nested style will apply a style of [None] to the digits as they need to be visible, but will intentionally hide the month.

So why I am I intentionally hiding the month? Because I’m only interested in the information it represents, and this can be called upon by a text variable. I will go to the master page and insert a text variable for a running header showing me the first result of hidden on the page.

The issue with the technique

That’s fine until I get to a spread that contains two months. I’d rather both months be present rather than the earlier month. For example, I’d like the headline to read April/May instead of April. I can do this by returning to my master page, apply my blinking text cursor to the text variable that is already there, type a slash and then create a new text variable that is a running header looking for hidden character style in the last instance.

Once I’ve inserted the variable and returned to that spread, that now looks fine, but all others are now affected.

I should be able to make a GREP style that will look for a word, then a backslash, and the same word it initially found. I’ll create a new text frame with some sample text to see if it works. The GREP code I’ll use is this:

Apply style: Hidden

GREP: (.+?)\K\/\1

Looks like its working in my demo, but as I check the document it isn’t… I’ll find a spread where I know the months split.

But that should work. I saw it work on plain text, why isn’t it working on text variables? That’s because GREP styles and Nested Styles don’t work on text variables. If I want this technique to work, I’ll have to use a workaround.

The workarounds:

  • Use a script to convert the text variables to plain text. Marijan Tompa used to have such a product via the Adobe Exchange, but it has since been removed, and it is not mine to give away. Other scripts do exist on the Adobe InDesign forums, but they are not as flexible as Marijan’s original script. It also works only one way, and can’t convert the text back to variables.
  • Don’t attempt to use the GREP style to hide the duplicate month, but instead only add a Running Header for the first instance on a page and add the others manually by overriding the affected master pages;
  • Create the desired date in Excel using a formula.

The issue with the first two solutions is that it prevents the solution from remaining live. The last solution will work but requires in-depth knowledge of Excel and – for many diaries – requires having an Excel file on stand-by for this purpose.

Ultimately, I’d love to see a fix for this issue as it would open up many possibilities. If you feel that this needs attention now rather than later, please cast your vote here.

Referencing pages of a multi-page PDF file during data merge… workaround

At the time of writing, there are three multi-page/artboard file formats that Adobe InDesign can import when placing a file via the File/Place function. These formats are:

  • PDF
  • Adobe Illustrator
  • Adobe InDesign

(While it is possible to create many artboards in Adobe Photoshop, it is not possible to import a specific Photoshop artboard into Adobe InDesign… – at the time of writing that is – but that is another article!)

When placing one of these three formats, it is possible to control several import functions using the show import dialog box, such as:

  • Which page (or pages) to import;
  • How the pages should be cropped;
  • Whether or not to place the pages with a transparent background; and
  • What layers to show and their visibility;

However, when importing these file types as variable images during a data merge, these options are unavailable and replaced with the following:

  • Only the first absolute page of the file is imported (not always the page numbered 1 as the first page can also be – for example – in roman numerals or start at a page other than one); and
  • Page cropping, transparency and layer visibility is determined by the same variables as the last file of that type to be placed into the artwork.

For now, there is no workaround to control the latter issues during a data merge, other than to be familiar with this behaviour and plan the merge accordingly. There is a workaround for importing pages beyond the first page of a PDF file… but not an Illustrator or InDesign file.

Workaround: Split the PDF

The term “workaround” is used loosely in this context. Unfortunately, the solution is to break the PDFs into single page records. This can be done within Acrobat using the split button from the organise pages panel.

This feature also allows multiple files to be split at once.

By default, the resulting files will maintain the same filename with the addition of _Partx prior to the filename, with x representing the absolute page number.

Otherwise, I’ve prepared an action that you can download here that will save the PDFs to the Documents folder of the machine running the action.

(Yes, I’m also aware that there are quite literally hundreds of websites out there that will split multi-page PDFs to single PDFs for free. However, the methods outlined above will do so without involving a third party).

The next part of the workaround involves the data itself, and I’ll be using Microsoft Excel to create formulas to make the numbering for the resulting pages. All variable images being referenced will also be in the same folder as the data file, meaning only the filename is required and not the full path and the filename.

For data where the page number is known

Add a column to the database that references the absolute PDF page number that needs to be imported.

Absolute vs Section numbers abridged:

Absolute numbers refers to a page number based on the total count of pages in the document, while section numbers refers to the page number that was applied using page numbering in the application that made the PDF.

For example, take a PDF that contains 20 pages with the first six pages being in roman numerals, and the remainder being in decimal numbers. These two different styles of numbering are section numbers, while absolute page numbers refer to the total count of pages. To reference page iv of the PDF, the absolute page number to reference is 4. To reference page 5 of the PDF, the absolute page number reference is 11.

In this example, the A column represents the PDF to reference, the B column represents the absolute page number, and C represents the result. To obtain this result, the following formula can be used:

=SUBSTITUTE(A2,".PDF","_Part"&B2&".pdf")

This formula will look at filename reference and substitute the .PDF portion of the filename for _Partx.pdf, where x represents the figure in the B column. Using this formula, only filenames with the PDF extension will be affected, while filenames in other formats will be unaffected.

For data where the page reference needs to increment by one more than the row above

The same formula can be used for the naming, but another formula is used to determine if the page reference should increase if the same base file is being referenced in the row directly above.

In this example, the N column represents the PDF to reference, the O column represents the absolute page number, and P represents the result. A 24 page file NS91912 is being merged and needs to have the page reference incremented by one so that the filenames are NS91912_Part1.pdf to NS91912_Part24.pdf. The following formula can be used to change the page reference:

=IF(N2=N1,O1+1,1)

This formula will look at the filename and determine that if the filename is different to the row above, put the number 1 in the cell, BUT if the filename is the same as the row above, take the page value from the cell above and add 1 to it into this cell.

In a perfect world

Again, this is a workaround – it will only work for PDFs and requires some upfront work to prepare. Ideally, if I had my way and could implement some improvements, I’d like to see:

  • Not just the ability to choose a specific page, but choose the correct trim box and layers as well. For example, a file reference such as myFile.pdf;1,trim;Layer1,Layer2 where 1 represents the absolute page number, trim represents what trim box to use, and Layer1,Layer2 represent the layers I would like to appear (or leave the layer bit blank if all layers should be visible).
  • The ability to perform a similar task for incoming INDD, AI or PSD files.
%d bloggers like this: