line-breaksidml

IDML RightIndentTab causing line break


I am working on IDML files which are used by InDesign. I am facing a problem in inserting a special instruction. I need to embed RightIndentTab with IDML file. The unicode for the same is U+0008. When I try to add that it throws error as this unicode is not supported in XML specs.

I looked more into it and IDML has a special Processing Instruction which can be inserted it looks like now the problem is when I add this it introduces a line break before the RightIndent symbol. On debugging I found that the content element looks like

             <Content>
                <?ACE 8?>9731396</Content>

It is an XElement and I see \r\n when I call ToString() on it. I also tried using XmlWriter.

What I would like is an XElement object which looks like

             <Content><?ACE 8?>9731396</Content>

Thanks in advanced!


Solution

  • I've encountered exactly the same problem adding processing instructions to IDML, using .NET. Even with significant whitespace turned off I got a line break that InDesign treats as part of the text.

    The only solution I have found is to save the file as XML, then open it as a text document and use a regular expression to replace >\r\n<? with just ><?. It's ugly and kludgy, but it does work - I don't have the regex to hand but you should be able to figure it out fairly quickly.

    I've never had any problems adding unicode chars to XML, though. I would just use &#x0008; and also set the XmlWriter encoding to use unicode. See here for an example: http://bytes.com/topic/net/answers/176665-how-write-unicode-using-xmlwriter which recommends:

    XmlTextWriter myWriter = new XmlTextWriter( fileStream,
    new System.Text.UnicodeEncoding( false, false) );