RichPaste | Copy and Paste with Minimal Formatting [UPDATE]
April 06, 2016 | Snippets | en | fr
When it comes to pasting text from another document or application, InDesign provides two options, either keeping the original text attributes, fonts, styles (the full 'Paste' feature), or removing all attributes ('Paste without formatting'.) We also have tools and preferences in the field of style mapping, but on many occasions these features do not fit the need of dealing quickly with basic formatting problems. Here RichPaste comes to the rescue…
Update (6-April-2016). — RichPaste 1.7 provides minor bug fixes regarding file management. Remember that the script file, RichPaste.jsx
, must be installed as any other regular script—this is not a 'startup script.'
Update (12-Jan-2016). — RichPaste 1.6 brings important bug fixes (in particular those related to menu integration) and several improvements. The script is now localized in German thanks to my colleague Uwe Laubender who also provided valuable assistance in fixing the reported issues. Support for subscript and superscript attributes has been added. Oblique fonts are now recognized as italic variants.
How to install the update?
1. Quit InDesign.
2. Put the new version of RichPaste.jsx
at the location of the existing file.
3. Restart InDesign.
4. Run RichPaste.jsx
from the Scripts panel. (You may be prompted that a new version is installing.)
5. Done. You can close the Scripts panel and run RichPaste from either the Edit or the Right-Click menu.
The Problem
I am almost certain that every typographic designer has had to lay out such kind of material:
To turn into a real book a Word document so generously formatted (by an evil author) you usually have no choice but to remove all flourishes, then to apply the typographic rules of the publisher.
The problem is, erasing any formatting may also delete a substantial part of the content, since italics, and/or underlining, often contribute to the message in a way that cannot be regarded as purely cosmetic. 'Paste without formatting' will radically reset the original message:
The Solution
Instead, it would be useful to selectively preserve some minimal formatting while preventing the target document from being altered by wild fonts, imported styles, and so on. A good balance could be something like this:
That's the purpose of our script of the day: RichPaste. It offers a basic interface where you can select those minimal attributes you wish to preserve while rich-pasting into InDesign:
The options speak for themselves. Use the Extra Font fields to preserve specific fonts (e.g. Arial-Regular
), otherwise leave these fields empty. Your preferences are persistently stored—til you change them! Turn on the option “Do not show this dialog before pasting” to skip the setting stage when you execute RichPaste. You can still recall the Preferences dialog from either the right click menu, or from the Edit menu:
As you have noted a new menu item, Paste with formatting | RichPaste, has been added too. It also appears in the right click contextual menu, which provides a quick way to run the script from any selection or insertion point context:
Note. — The first time you execute the script—that is, from the Scripts panel—it automatically sets up its menu system in InDesign so you won't need to call back the Scripts panel at all.
Installation. — RichPaste being a regular JSX
script, put it as usual in your 'Scripts Panel' folder and you're done. Behind the scene the script generates an additional startup file in order to manage the menus but that should be transparent to the user. (Do not put the script itself in a 'startup scripts' folder.)
Possible Issues
Various issues, or just unsatisfactory results, may occur depending on either your InDesign settings, font status/availability, or the inner state of the clipboard while the script is running. There are obscure cases—at least obscure to me!—where InDesign is simply unable to retrieve formatting or font styles from the clipboard even when the external application clearly supports rich text management through copy/paste.
RichPaste properly recovers embedded footnotes, but for the time being it does not deal with their original formatting attributes. In practice they should be composed with respect to your current footnote options, keeping in mind that InDesign has a long history of erratic behavior in this area!
Comments
How come this is already 1.4 and I never heard of it ? :)
Except the "extra work" feeling, what do you think of not only preserving bold/ital/underline, but also assigning dedicated (existing) character styles to those things we preserve ?
I know there's also this very strange thing to deal with when start of the line is bold, middle is bold-italic, end is italic only. 3 Character styles in inDesign, which makes it one step further of complication (and I could manually deal with that later)
Great script! (although I seem to be unable to download it at the moment)
Would it not also be possible to make the script create placeholder character styles based on the formatting it finds? I.e. not character styles that try to recreate the original style visually, but just „empty“ character styles that are already applied to the text style ranges and can then be set up typographically by the InDesign operator.
Hi Franck & MD,
I *knew* character style mapping would be mentioned here ;-)
italic formatting → MyItalicStyle
bold formatting → MyBoldStyle
etc.
Indeed version 1.4 does not provide this mechanism, basically for two reasons. First, adding character style mapping options in the UI dialog is a nightmare. Furthermore, mapping styles is in itself a possible script beyond the specific purpose of RichPaste. (Meanwhile, I still consider find/change queries as a decent solution in that scope.)
@Franck
Yep, there was a very unofficial pre-prerelease of RichPaste 1.4. In fact, the old name of this script was “SmartPaste.” The URL was hidden but already disclosed to some of my fans and Twitter followers ;-)
@+,
Marc
Hi Marc,
Very nice script. But don't you think that super- and subscript and strikethrough should be preserved as well?
Peter
J'aime beaucoup ce script, qui une fois encore, répond à un vrai besoin, lors d’import vers ID...
A nouveau un grand merci, je vais le pousser un peu pour en constater les avantages.
Thanx again Marc.
Hyper intéressant !
Bravo et merci beaucoup...
en revanche, je n'ai rien compris pour installer le script :(
Merci de votre aide
Franck
Bonjour Franck,
> je n'ai rien compris pour installer le script :(
Rassurez-vous, RichPaste est un script InDesign tout ce qu'il y a de plus classique :
— tout d'abord, téléchargez le fichier RichPaste.jsx (clic droit, enregistrer sous…),
— puis installez-le selon la procédure habituelle indiquée ici : http://www.indiscripts.com/pages/he...
@+
Marc
I can’t get menu integration to work. The "startup scripts" folder gets created but remains empty in C6/CC14/CC15 (Mac 10.11.4/German). Any ideas?
I found the Problem: Though i put the script in my user scripts panel the startup scripts would be put into the apps startup scripts. This of course doesn’t work for non-admin users. I would call this a BUG. ;)
Hi rP,
Thanks. You are perfectly right. In my F_GET_STARTUP_FILE function I should process the user stuff *before* the app stuff in order to give precedence to user location.
Will be fixed.
@+
Marc
Il semble que le même souci (que rP décrit ci-dessus) dû à un profil "non administrateur" se confirme sur mon PC. Le script est installé et fonctionne, mais ne peut être appelé ni par le menu Édition, ni par le clic-droit.
(Indesign CS6/Windows)
Bonjour Nico,
Merci pour votre commentaire (et désolé pour mon extrême latence).
> Le script est installé et fonctionne, mais ne peut être appelé
> ni par le menu Édition, ni par le clic-droit.
Est-ce à dire que les menus en question sont carrément absents, ou bien qu'ils sont présents mais non fonctionnels ? Cette petite nuance pourrait me fournir un indice salutaire.
@+
Marc
I would like to use this script for a bigger project, but unfortunately the "target" font doesn’t use "bold" but "demi" or "medium" styles. Any ideas how to map "bold" to "demi", "medium" or the like?
Hi rP,
Line 756 of the script you have:
destParams = I.SCAN_SELFONT_FORMATTINGS(sel);
The object destParams will then contain the names associated to the font variants for bold and ital, ordered as follows:
destParams[0] : normal font name
destParams[1] : italic font name
destParams[2] : bold font name
destParams[3] : bold+ital font name
So if you already know the target font and the desired variants (demibold, etc.) you can hack the script by rewriting the destParams just after line 756.
E.g.
destParams[2] = "MyTargetFont^tSemibold";
and so on.
@+
Marc
Marc,
A mon tour de vous prier d'excuser une réponse tardive : le menu n'est pas présent, je ne peux accéder au script que via la palette des scripts...
A vous lire,
Nico
@ Nicolas
> le menu n'est pas présent (…)
Même avec la version 1.7 de RP ?
Marc, je viens d'installer la version 1.7, le menu apparait bien dans la fenêtre "édition" d'InDesign, et lors d'un clic-droit, dans le menu contextuel...
Parfait donc...!
;-)
Grand merci à nouveau,
Nico
Bonjour,
Merci pour votre script… mais lorsque sur mon Macintosh (OSX 10.11.5 Capitan) je veux copier un texte depuis Office 365 vers InDesign CC 2015 (dernières versions des deux logiciels), j'obtiens les messages d'erreur suivants :
— Un script associé a généré l'erreur suivante :
undefined is not an object
Voulez-vous désactiver ce gestionnaire d'événements ?
— Les variantes italiques et/ou gras n’ont pas pu être identifiées.
Que dois-je faire ?
D'avance merci de votre réponse.
Bien cordialement,
Olivier
Merci Olivier pour ce signalement de bug. J'étudie la question et vous contacte par courriel.
@+,
Marc
I had a few issues with bolds and italics being displaced by RichPaste along the text. I could fix it by making sure to select "All information" under ID Preferences->Clipboard handling before pasting.