Copy link to clipboard
Copied
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
I'd prefer that too, and after changing the content doing a IDML export to overwrite the existing IDML file…
Uwe
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
@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
Copy link to clipboard
Copied
If I go with your idea, how can I place the new "snippet" back into Indesign?
Thanks!
-Lloyd
Copy link to clipboard
Copied
@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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I'd prefer that too, and after changing the content doing a IDML export to overwrite the existing IDML file…
Uwe
Copy link to clipboard
Copied
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!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now