How to merge IDML documents/How to rename IDML based on found value in Stori

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / How to merge IDML documents/How to rename IDML based on found value in Stori

Viewing 8 reply threads
  • Author
    Posts
    • #90797
      Justin Sligh
      Member

      I use a web-based database that exports single page documents as separate unnamed IDML file.

      Im looking into how to create a script/droplet that can:

      1. merge multiple IDML files
      2. save as INDD

      else
      1. For each IDML, find value of <Content> where the AppliedCharacterStyle of <CharacterStyleRange> is “CharacterStyle/Project Title”
      2. Rename the IDML with that value

    • #90810

      Both seems to be possible, but need a bit more information and surely testing. If you are interested in a paid script, you can mail me at [email protected]

      Kai

    • #90900
      Loic Aigon
      Member

      FWIW, I have been interested long time in the idea of merging idml files without getting really further from the idea. However when I confronted my project to other dev fellows, the general consensus was that it was a deadend, mostly for IDs issues.
      So I guess the only “true” way of merging indesign files is actually to open those and relocate pages. As for the naming, it’s quite easy to find text which style is applied on.
      Unless I am wrong.
      Loic

    • #90901

      Loic, that’s my understanding too. Since the OP want a named indd, I would open every idml and move the pages from idml2 to idml1 …

      Kai

    • #90907
      Justin Sligh
      Member

      I explored an Applescript solution with some minor success. PHP is about the only language I speak. Ill keep exploring.

    • #91014
      Justin Sligh
      Member

      I have a working Applescript but was unable to post to the forum.

      • #91023
        David Blatner
        Keymaster

        Sorry, Justin. Not sure why that got caught up. I’ve published it now.

    • #91012
      Justin Sligh
      Member

      Here is the Droplet i came up with. To add error correction and flexibility, I may add the following:
      1. Check to see if output filename provided is already used in the output folder.
      2. Get the CombinedDocument’s preferences from the first file. (it is hard coded into mine but it might not matter as mine deletes the first (blank) page.
      3. Provide support for filtering filetypes
      4. Provide support for dropping folders (getting the first tier results of the contents)
      5. Provide a dialog that indicates broken links or overset text in the combined document on completion

      on run {input, parameters}
      --Choose Output Folder
      tell application "Finder"
      set OutputFolder to choose folder with prompt "Select a folder for output"
      set myFilelist to input
      set myFileCount to count of myFilelist
      end tell
      log myFileCount
      if myFileCount > 0 then
      --Get output filename
      display dialog "Please provide the name for the combined file" default answer ""
      set SaveNameInput to text returned of result
      set SaveName to SaveNameInput & ".indd"
      --Need to add check if filename already exists
      tell application "Adobe InDesign CC 2017"
      activate
      set user interaction level of script preferences to never interact
      tell view preferences
      set horizontal measurement units to inches
      set vertical measurement units to inches
      end tell
      --setup combined document
      set myCombinedDoc to make document
      tell document preferences of myCombinedDoc
      set page height to "8.5"
      set page width to "11"
      set page orientation to landscape
      set pages per document to 1
      set facing pages to false
      set allow page shuffle to false
      end tell
      repeat with i from 1 to myFileCount
      open (item i of myFilelist)
      delay 10
      set myCurrentFile to the active document
      tell myCurrentFile
      set DocName to name
      log DocName
      duplicate every spread of myCurrentFile to after last spread of myCombinedDoc
      close saving no
      end tell
      end repeat
      tell myCombinedDoc
      set SavePath to (OutputFolder as string) & SaveName
      log SavePath
      delete page 1
      save to SavePath
      close saving no
      end tell
      set user interaction level of script preferences to interact with all
      beep 3
      display alert "Complete" giving up after 3
      end tell
      else
      display dialog "No IDML files to process" giving up after 3
      end if
      return input
      end run

    • #91686
      Justin Sligh
      Member

      I have a functioning solution in PHP. This one will query a database and replace placeholders within IDML templates. It also combines multiple IDML files. I may publish when I have added error handling.

      Placeholders are wrapped in percent signs. %PlaceholderName%

      1. For each result in the database query, PHP class unzips the selected template to a work folder with a unique name.
      2. The Story_XXX.xml files that include placeholder names are selected.
      3. Find/Replace is performed on the array of placeholders and the database results.
      4. Once all of the placeholders have been handled, the story and spread Ids are made unique. This includes the filename and references within spreads. An array keeps track of these changes.
      5. The first template folder is designated the combined workspace. All of the other template stories and spreads are dumped into the appropriate holders.
      6. The combined workspace’s designmap.xml is opened as a DOMDocument and the new spreads and stories are added.
      7. The combined document is zipped (The mimetype from the template is incorporated.)

    • #91697
      Loic Aigon
      Member

      Nice.

Viewing 8 reply threads
  • You must be logged in to reply to this topic.
>