Skip to main content
Sakotanis
Participant
September 24, 2021
Question

Trying to paste RTF raw code into Indesign - possible?

  • September 24, 2021
  • 1 reply
  • 147 views

Hello,

I'm trying to import Data from and database created xml file into Indesign. Working ok so far, but:

Some of our imported Texts include rtf code, eg:

<PT6>{\rtf1\ansi\ansicpg1252\deff0\nouicompat{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}{\f1\fswiss\fprq2\fcharset0 Arial Narrow;}{\f2\fnil\fcharset0 MS Sans Serif;}{\f3\fnil\fcharset2 Symbol;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Riched20 14.0.7155.5000;}{\*\mmathPr\mwrapIndent1440}\viewkind4\uc1
\pard\sa200\sl276\slmult1\cf1\b\f0\fs17\lang3079 Hotelinformation:\b0\par
Das historische, direkt neben dem Stadtstrand gelegene ****Hotel Palace Bellevue hat den altehrw\'fcrdigen Charme und die Eleganz der k. u. k. Monarchie bewahrt.  \par
}
</PT6>

 Unfortunately Indesign doesn't interpret this as rtf - of course, how should it know.

Saving as rtf file and placing works fine, but is not an option in the workflow.

 

Is there a way to mark this code for Indesign to parse correctly?

Any hint is greatly appreciated!

Thanks,

Sakotanis

 

This topic has been closed for replies.

1 reply

Joel Cherney
Community Expert
Community Expert
September 24, 2021

Saving as rtf file and placing works fine, but is not an option in the workflow.

 

I assume that what you want is doable, but it seems like a lot of heavy lifting - basically writing some JS that looks for RTF markup and then... implement an RTF-parser in JS? There are no InDesign tools to parse RTF markup outside of its RTF importer, as far as I know. I've seen a few halfway-finished RTF parsers available, via github or npm, and some that look complete but are written in contemporary JS instead of our ancient dialect of ExtendScript, so there'd be some work in making that code old-fashioned enough to run in ID. 

 

However, this really seems like something that should be processed before you import the XML into ID. "Database generated XML" means that somebody somewhere wrote a tool that hits your DB and generates XML, right? On Sharepoint, it looks like. And that person is completely unavailable to you, I'm guessing. So you can't fix it (or ask the actually responsible parties to fix it) at the source, and InDesign can't fix it at the target, in InDesign (without either extracting RTF bits and resaving 'em as RTFs, which you say won't work for you, or implementing an RTF parser in JS in ID, which sounds like A Fair Bit of Work). 

 

So, I'd look into preprocessing the XML when it is a separate text file. Is your workflow expected to carry the formatting in the RTF into your file? Or is it just the text content? Because if all you really need in the RTF blob is that Hotel Information, that'd be easy to extract with e.g. a regular expression in Notepad++, or your text editor of choice that has a regex implementation. 

 

I'm guessing that, if you wind up reading this and replying to it, you can come up with some great reasons why my ideas won't work. If so, feel free to post 'em, because once we know more about your precise situations and limitations, it'll be much easier to make useful suggestions.