Skip to main content
Jens Troeger
Inspiring
January 2, 2017
Question

How do I load an ICML File?

  • January 2, 2017
  • 2 replies
  • 4799 views

Hello,

Chapter 12 of the Javascript Scripting Guide talks about loading XML files into elements of an InDesign document, and about styling them using tags-to-style mappings. Given an InCopy ICML file, however, how do I place its content in a document? Using that same XML facility, or is there another and better way of loading and placing ICML files into InDesign documents?

Thank you,

Jens

This topic has been closed for replies.

2 replies

Community Expert
January 3, 2017

Hi Jens,

you could check what placeable file extensions can be used:

// Writes the result to the JavaScript Console of the ExtendScript Toolkit (ESTK)

app.placeableFileExtensions.sort().join("\r");

// Result for e.g. InDesign CS6 v8.1.0 on Mac OSX:

AI

AIF

AIFF

AU

AVI

BMP

CT

DCS

EMF

EPS

F4V

FLV

GIF

JPE

JPEG

JPG

M15

M1A

M1S

M1V

M64

M75

MOV

MP2

MP4

MPA

MPEG

MPG

MPM

MPV

PCC

PCT

PCX

PDD

PIC

PMG

PNG

PSD

RLE

SCT

SWF

TIF

TIFF

TP1

TRP

TXT

WAV

WAVE

WMF

doc

doc

docx

icml

idms

incd

incx

indd

inds

indt

joboptions

mp3

oam

pdf

pdp

rtf

txt

utxt

xls

xlsx

However, I did not test, if all of these will work for the Mac version.

And InDesign will be agnostic on cases:

E.g. myDocument.jpg and myDocument.JPG will work alike.

Regards,
Uwe

grefel
Community Expert
Community Expert
January 3, 2017

You simply place the ICML-File into a Textframe:

app.activeDocument.textFrames[0].place(icmlFile); 
// optional unlink
dok.links.itemByName(icmlFile.name).unlink();
Jens Troeger
Inspiring
January 3, 2017

grefel​ Thank you for mentioning the TextFrame.place() method, that’s what I was looking for. It takes a File argument though, and Javascript’s File class doesn’t seem to implement a wrapper for a string or stream (which is how the ICML arrives in my case). I might be able to use a temporary file in local storage though, I shall poke around...

I also noticed that line breaks and spaces in the ICML file are replicated exactly, including page breaks that I haven’t quite figured out where they come from.

Thank you!

grefel
Community Expert
Community Expert
January 11, 2017

There is no wrapper for String or Stream. I would write a temporary file to disk.