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

Update IDML with indesign script?

Guest
Aug 04, 2010 Aug 04, 2010

Hello,

In an Indesign Script (javascript), after I loop through the page items and find the text frame I wish to edit, I am wondering if it is possible get the IDML from that TextFrame, and then update it, and replace its current IDML with the updated version.

I only will need to update one of the Story.xml files within the IDML package. Is this possible?

Thanks in advance!

-Lloyd

TOPICS
Scripting
3.1K
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

correct answers 1 Correct answer

Community Expert , Aug 05, 2010 Aug 05, 2010

I'd prefer that too, and after changing the content doing a IDML export to overwrite the existing IDML file…

Uwe

Translate
New Here ,
Aug 05, 2010 Aug 05, 2010

Hi Lloyd,

i dont know if it is possible with javascript, but there is a IDML library called IDMLlib http://idmllib.com

This lib is able to modify IDML files without InDesign. So it is not a big deal to change the story of a textframe.

regards

Peyman

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 ,
Aug 05, 2010 Aug 05, 2010

@lhanneman:

A different workflow: you could try to export that text frame as a snippet (*.idms) from InDesign. Basically a snippet in InDesign CS4 and above is nothing else as a chunk of IDML, so you can easily edit it with a text editor or via scripting, then place it back to InDesign.

Note 1: the story identifier <Story Self="sometext" is apparently the same, both in the idms-snippet and in the idml-file of the whole document.

Note 2: stories inside an IDML are stored separately by their idmlComponentName plus the .xml-suffix in the Stories-subdirectory.

Note 3: also look for the javascript property idmlComponentName of the story of your text frame…

Example:

idms: <TextFrame Self="ue3" ParentStory="ud1"

idml: Story_ud1.xml : <Story Self="ud1"

InDesign scripting: myTextFrameOfInterest.parentStory.idmlComponentName => "Story_ud1"


Hope that helps.

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
Guest
Aug 05, 2010 Aug 05, 2010

Laubender,

If I go with your idea, how can I place the new "snippet" back into Indesign?

Thanks!

-Lloyd

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 ,
Aug 05, 2010 Aug 05, 2010

@Lloyd: by thinking more deeply of your task, it seems to me, that you will go the following route:

You start with an existing IDML file you want to manipulate (you stated so by choosing the title of this thread by "Update IDML"), no need to change the source:


1. Unpack the IDML file with scripting (see "unpackageUCF (ucfFile: File, destinationFolder: File)" in the documentation)
2. Do your stuff

2.1 search all story.xml files for your text string and it's parent story you want to change or by identifying your story using "idmlComponentName" on the source

2.2 do the change by reading and writing the xml-file

3. Repackage the IDML file and give it a new name (see "packageUCF (sourceFolder: File, ucfFile: File)" in the documentation)

However, if you want to place an updated snippet, you can use the place command as usual; be aware that there are additional options in preferences to export and place a snippet to confirm to its IDML-format during export and there is a "place in original location" option for placing:

DocumentPreferences: snippetImportUsesOriginalLocation
application: snippetExportFormat: SnippetExportFormats.INX_EXPANDED_FORMAT (for generating an IDML-snippet instead of an INX-snippet)

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 Expert ,
Aug 05, 2010 Aug 05, 2010

Somehow I think it would be far easier to 1. identify that particular text frame by assigning it a unique label, then 2. use that in a script to change its contents.

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 ,
Aug 05, 2010 Aug 05, 2010

I'd prefer that too, and after changing the content doing a IDML export to overwrite the existing IDML file…

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
Guest
Aug 06, 2010 Aug 06, 2010
LATEST

But what if the text within the text frame has multiple styles? I could easily replace the text within the frame, but what if some text in the frame is styled one way, and other text styled another? Then what if the text I am replacing it with has different or no styles at all?

thanks in advance!

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