Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[VB/C#] Setting text as content without losing format information

Community Beginner ,
Nov 28, 2017 Nov 28, 2017

Hello everyone!

I would like to set the Contents field of an InsertionPoint (or other object) from a database in a way that allows me to pass format information.

Sample text: "This is a text"

This is what I currently can do:

InsertionPoint ip;

ip.Contents = "This is a text";

Of course this means that I will lose all format information, so I have some pretty complicated code that splits the text in several sub-groups ("This", " is a " and "text") and sets the contents and styles for those. If at all possible, I would like to simplify this.

So, as mentioned in the first sentence, my question is: Is there any way to set the Contents field with format information?

I currently use Visual C# 2017 and InDesign CS6. An upgrade to CC is already scheduled. InDesign is accessed via Interop.InDesign.

Any help is highly appreciated!

Best regards,

Hans

TOPICS
Scripting
543
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2017 Nov 28, 2017

Hi Hhans,

Other than applying a GREP style or a nested style through a paragraph style I see no way of doing this.

Both include rules or patterns how is what formatted using character styles.

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 30, 2017 Nov 30, 2017

Hi Uwe,

thanks a lot. I will look into both options. May be I can use one of them.

Best Regards,

Hans

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2017 Nov 30, 2017

Hi Hans,

hm… You said that InDesign CC is on its way to your machine 🙂

This means a huge gap in functionality between CS6 and CC 2018.

Unfortunately in regards of assigning contents nothing has changed in the DOM.

But:
The title of this thread says [VB/C#]. Check, if there are any problems with e.g. VB Script (if this relevant to you) and InDesign CC 2018. I think, I saw some reports on this here in the scripting forum. Could be wrong. Basically I'm on Mac OSX…

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 30, 2017 Nov 30, 2017

Hi Uwe,

Oh, I started developing my program back in the days of InDesign 2. And with every new version that my customer bought, I had to adapt quite a few things. I fully expect having to do the same with CC 2018. It's already on my PC btw., just not on the customer's yet.

Best Regards,

Hans

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 01, 2017 Dec 01, 2017

My couple of cents:

Check out xTags.

If your date base software is capable of generating the output using the xTags language, you'll be able to easily apply any formatting (e.g. bold, italic, super/subscript, par/char styles, etc.) to the text by script. Also, you'll be able to replace 'image' tags with images applying all the necessary formatting (e.g. width, height, scaling, skew, border, etc.).

— Kas

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 05, 2017 Dec 05, 2017
LATEST

Hi Kas,

xTags might be a solution for my problem. I will look into it. Thanks for the heads up 🙂

Best Regards,

Hans

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines