Script lifted from Adobe's inDesign script examples doesn't work

G’day,

I need to check inDesign files for basic fonts & links only, in Applescript, but this crashes on 'Font status’ and on 'count graphics of myDocument’

It’s basically lifted straight from the Adobe scripting document, InDesign CS3 Scripting Guide.

Can some one please tell me what’s wrong with it?

Regards

Santa


tell application "Adobe InDesign CS3"
	set myDocument to document 1
	set myFontCheck to true
	repeat with myCounter from 1 to (count fonts of myDocument)
		set myFont to font myCounter of myDocument
		if font status of myFont is not installed then
			set myFontCheck to false
			exit repeat
		end if
	end repeat
	
	set myGraphicsCheck to true
	repeat with myCounter from 1 to (count graphics of myDocument)
		set myGraphic to graphic myCounter of myDocument
		set myLink to item link of myGraphic
		if link status of myLink is not normal then
			set myGraphicsCheck to false
			exit repeat
		end if
	end repeat
end tell

Hi Santa,

Adobe is really mad :wink:

In InDesign CS2:
the Font status property is just named status
the link status property is just named status
the graphics property is named all graphics

maybe this works also with CS3

tell application "Adobe InDesign CS3"
	set myDocument to document 1
	set myFontCheck to true
	repeat with myCounter from 1 to (count fonts of myDocument)
		set myFont to font myCounter of myDocument
		if status of myFont is not installed then
			set myFontCheck to false
			exit repeat
		end if
	end repeat
	
	set myGraphicsCheck to true
	set myGraphics to all graphics of myDocument
	repeat with myCounter from 1 to count myGraphics
		set myGraphic to item myCounter of all graphics of myDocument
		set myLink to item link of myGraphic
		if status of myLink is not normal then
			set myGraphicsCheck to false
			exit repeat
		end if
	end repeat
end tell

Thanks stefan.

Your script changes nearly worked, just needed a ‘font’ in an extra place


tell application "Adobe InDesign CS3"
	set myDocument to document 1
	set myFontCheck to true
	repeat with myCounter from 1 to (count fonts of myDocument)
		try
			set myFont to font myCounter of myDocument
			if status of font myFont is not installed then
				set myFontCheck to false
				--exit repeat
			end if
		end try
	end repeat
	
	set myGraphicsCheck to true
	set myGraphics to all graphics of myDocument
	repeat with myCounter from 1 to count myGraphics
		set myGraphic to item myCounter of all graphics of myDocument
		set myLink to item link of myGraphic
		if status of myLink is not normal then
			set myGraphicsCheck to false
			--exit repeat
		end if
	end repeat
end tell

Oops, I posted to soon.

I had foolishly wrapped the font bit in a try statement, and of course the errors weren’t trapped.

I’m back to square one with the font script not working, but the graphics part certainly works, thanks Stefan.

Santa

I recommend to read the dictionary (properties of document)

Note:

 set myFont to font myCounter of myDocument -- result is a font element
 if status of [font] myFont is not installed then -- so the font keyword isn't needed

G’day Stefan.

	get the status of myFont
	

does not work either, and I can’t make head nor tail of the dictionary

font‚n : A collection of fonts.
elements
contained by application, documents.
properties
allow editable embedding (boolean, r/o) : If true, the font can be embedded.
allow outlines (boolean, r/o) : If true, the font can be converted to outlines.
allow PDF embedding (boolean, r/o) : If true, the font can be embedded in a PDF document.
allow printing (boolean, r/o) : If true, the can font be printed.
class (type class, r/o) : The class descriptor type.
font family (string, r/o) : The name of the font family
font style name (string, r/o) : The name of the font style.
font style name native (string, r/o) : The native name of the font style.
font type (type 1/TrueType/CID/ATC/bitmap/OCF/OpenType CFF/OpenType CID/OpenType TT/unknown, r/o) : The type of font.
full name (string, r/o) : The full font name.
full name native (string, r/o) : The full native name of the font.
index (integer, r/o) : The index of the font within its containing object.
location (string, r/o) : The full path to the font.
name (string, r/o) : The name of the font.
object reference (font, r/o) : An object reference for the font.
ordering (string, r/o) : The ordering of a CID font.
parent (reference, r/o) : The parent of the font (a document or application). Can return: document or application.
platform name (string, r/o) : The platform font name.
PostScript name (string, r/o) : The PostScript name of the font.
properties (record) : A property that allows setting of several properties at the same time.
registry (string, r/o) : The registry of a CID font.
restricted printing (boolean, r/o) : If true, the font allows only restricted printing.
status (installed/not available/fauxed/substituted/unknown, r/o) : The status of the font.
version (string, r/o) : The font version.
writing script (integer, r/o) : The writing script.

Try this alternative

.
set myFontCheck to true
	repeat with theFont in (get fonts of myDocument)
		if status of theFont is not installed then
			set myFontCheck to false
			exit repeat
		end if
	end repeat
.

Here’s the event log…

tell application “Adobe InDesign CS3”
get document 1
document “100-74782_emboss printer.indd”
count every font of document “100-74782_emboss printer.indd”
2
get font 1 of document “100-74782_emboss printer.indd”
font “Optima (TT)” of document “100-74782_emboss printer.indd”
get status of font “Optima (TT)” of document “100-74782_emboss printer.indd”
“Adobe InDesign CS3 got an error: Can’t get status of font "Optima (TT)" of document "100-74782_emboss printer.indd".”

Big grin.

I posted the event log from my previous effort, but it reads the same with your script patched in Stefan

Santa :slight_smile:

Has the document class a font property or is it named different?

I’m afraid I don’t understand the question, what is a document class?

A Sorry Santa :wink:

Above you posted the properties of the class font.
Can you do the same for the class document?

document‚n [inh. ROOT] : A collection of documents.
elements
contains assignments, bookmarks, buttons, cell styles, cell style groups, character styles, character style groups, colors, dashed stroke styles, data merge image placeholders, data merge text placeholders, dotted stroke styles, DTDs, events, event listeners, fonts, form fields, gradients, graphic lines, groups, guides, hyperlinks, hyperlink external page destinations, hyperlink page destinations, hyperlink page item sources, hyperlink text destinations, hyperlink text sources, hyperlink URL destinations, hyphenation exceptions, indexes, indexing sort options, inks, languages, layers, layout windows, links, master spreads, mixed inks, mixed ink groups, numbering lists, object styles, object style groups, ovals, pages, page items, paragraph styles, paragraph style groups, polygons, rectangles, sections, spreads, stories, story windows, striped stroke styles, stroke styles, swatches, table styles, table style groups, text frames, text variables, tints, TOC styles, trap presets, validation errors, windows, XML comments, XML elements, XML export maps, XML import maps, XML instructions, XML Items, xml stories, XML tags; contained by application.
properties
accurate LAB spots (boolean) : If true, uses LAB alternates for spot colors when available.
active layer (layer) : The active layer. Can also accept: string.
after blending intent (use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric/use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric/use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric) : The rendering intent for colors that result from transparency interactions on the page after blending.
all cell styles (list of cell style, r/o) : All Cell styles
all character styles (list of character style, r/o) : Lists all character styles (regardless of their group).
all graphics (list of graphic, r/o) : Lists all graphics contained by the document.
all object styles (list of object style, r/o) : All object styles contained by the document.
all page items (list of page item, r/o) : Lists all page items contained by the document.
all paragraph styles (list of paragraph style, r/o) : Lists all paragraph styles (regardless of their group).
all table styles (list of table style, r/o) : All Table styles
anchored object defaults (anchored object default, r/o) : Anchored object default settings.
anchored object settings (anchored object setting, r/o) : Anchored object settings.
associated XML element (XML item, r/o) : The XML element associated with the document.
baseline frame grid options (baseline frame grid option, r/o) : Baseline frame grid option settings.
button preferences (button preference, r/o) : Button preference settings.
chapter number preferences (chapter number preference, r/o) : Chapter numbering preferences.
class (type class, r/o) : The class descriptor type.
CMYK policy (color policy off/preserve embedded profiles/convert to working space/combination of preserve and safe cmyk/color policy off/preserve embedded profiles/convert to working space/combination of preserve and safe cmyk) : The policy for handling colors in a CMYK color model, including reading and embedding color profiles, mismatches between embedded color profiles and the working space, and moving colors from one document to another.
CMYK profile (string) : The current CMYK profile.
CMYK profile list (list of string, r/o) : A list of valid CMYK profiles.
converted (boolean, r/o) : If true, the document was converted.
data merge options (data merge option, r/o) : The data merge option properties that define the data merge.
data merge properties (data merge, r/o) : Data merge properties that define data merge fields and preferences.
default image intent (use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric/use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric/use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric) : The rendering intent for bitmap images.
dictionary preferences (dictionary preference, r/o) : User dictionary preference settings.
document preferences (document preference, r/o) : Document preference settings.
editing state (editing unknown/editing nowhere/editing remotely/editing locally/editing locally locked/editing conflict/editing unknown/editing nowhere/editing remotely/editing locally/editing locally locked/editing conflict, r/o) : The Version Cue editing state of the file.
export for web preferences (export for web preference, r/o) : The default export for web preferences.
file path (alias or string, r/o) : The full path to the file.
footnote options (footnote option, r/o) : Footnote option settings.
frame fitting options (frame fitting option, r/o) : The frame fitting option to apply to placed or pasted content. Can be applied to a frame, object style, or document or to the application.
full name (alias or string, r/o) : The full path to the document, including the name of the document.
galley preferences (galley preference, r/o) : Galley preference settings.
grid preferences (grid preference, r/o) : Grid preference settings.
guide preferences (guide preference, r/o) : Guide preference settings.
index (integer, r/o) : The index of the document within its containing object.
index generation options (index options, r/o) : The index options properties that define how an index is formatted.
label (string) : A property that can be set to any string.
layout adjustment preferences (layout adjustment preference, r/o) : Layout sdjustment preference settings.
margin preferences (margin preference, r/o) : Margin preference settings.
metadata preferences (metadata preference, r/o) : Metadata preference settings.
modified (boolean, r/o) : If true, the document has been modified since it was last saved.
name (string, r/o) : The name of the document.
object reference (document, r/o) : An object reference for the document.
page item defaults (page item default, r/o) : The default page item formatting for the document.
parent (reference, r/o) : The parent of the document (a application).
pasteboard preferences (pasteboard preference, r/o) : Pasteboard preference settings.
print booklet options (print booklet option, r/o) : Booklet printing options.
print booklet print preferences (print booklet print preference, r/o) : Print booklet preferences.
print preferences (print preference, r/o) : Print preference settings.
properties (record) : A property that allows setting of several properties at the same time.
read only (boolean, r/o) : If true, the document is read-only.
recovered (boolean, r/o) : If true, the document was recovered.
redo history (list of string, r/o) : The names of the items in the redo stack.
redo name (string, r/o) : The name of the action on the top of the redo stack.
RGB policy (color policy off/preserve embedded profiles/convert to working space/combination of preserve and safe cmyk/color policy off/preserve embedded profiles/convert to working space/combination of preserve and safe cmyk) : The policy for handling colors in an RGB color model, including reading and embedding color profiles, handling mismatches between embedded color profiles and the working space, and moving colors from one document to another.
RGB profile (string) : The current RGB profile.
RGB profile list (list of string, r/o) : A list of valid RGB profiles.
saved (boolean, r/o) : If true, the document has not been saved since it was created.
selection (list of reference) : The selected object(s). Can also accept: object or nothing.
solid color intent (use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric/use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric/use color settings/perceptual/saturation/relative colorimetric/absolute colorimetric) : The rendering intent for all vector art (areas of solid color) in native objects.
story preferences (story preference, r/o) : Story preference settings.
text defaults (text default, r/o) : Text default settings.
text frame preferences (text frame preference, r/o) : Text frame preference settings.
text preferences (text preference, r/o) : Text preference settings.
transparency preferences (transparency preference, r/o) : Transparency preference settings.
undo history (list of string, r/o) : The names of the items in the undo stack.
undo name (string, r/o) : The name of the action on the top of the undo stack.
unused swatches (list of swatch, r/o) : The swatches that are not being used.
version state (version unknown/project file newer/local project match/local newer/version conflict/no resource/version unknown/project file newer/local project match/local newer/version conflict/no resource, r/o) : The Version Cue version state of the file.
view preferences (view preference, r/o) : View preference settings.
visible (boolean, r/o) : If true, the document is visible.
XML export preferences (XML export preference, r/o) : XML export preference settings.
XML import preferences (XML import preference, r/o) : XML import preference settings.
XML preferences (XML preference, r/o) : The XML preference settings.
XML view preferences (XML view preference, r/o) : XML view preference settings.
zero point (list of number or string) : The ruler origin, specified as page coordinates in the format [x, y].

Thanks, Santa, but at this point I have to give up.
The syntax is correct (class document has an element fonts) and I havn’t CS3 (yet) to try it

I’ve posted on Adobes website, but i think I’ll not get an answer there either.

I suspect a bug, and not the first one I’ve discovered in the CS3 Suite. :confused:

Thanks Stefan.

If you’re ever in Oz, I owe you a beer (or two)

Regards

Santa

Santa,

If you are looking for a list of fonts and graphics that are not available then all you need to do is:

tell application "Adobe InDesign CS2"
	set MissingLinks to every link of document 1 whose status is link missing
	set MissingFonts to every font of document 1 whose status is not installed
end tell

This works in CS2 and returns a list of object references for the missing links and fonts which are not installed. You can then loop through those to lists to do what you need to do with them.

G’day Jerome

Unfortunately I’m working with CS3, and the ‘status of font’ doesn’t work anymore.

Neither does their suggested ‘Font status of font’, lifted directly from Adobe InDesign scripting for CS3 document.

Regards

Santa

Jerome, I owe you an apology.

Out of desperation I tried your script, and the font part works with CS3.

Unfortunately the links part doesn’t, so I’ve ended up with a mish-mash of code.

Thank you. & regards

Santa


	set myFontCheck to (count (every font of document 1 whose status is not installed)) = 0
							if not myFontCheck then say "[[rate " & TheSpeechRate & "]]There are fonts missing. " using TheVoice
							set myGraphicsCheck to true
							set myGraphics to all graphics of myDocument
							repeat with myCounter from 1 to count myGraphics
								set myGraphic to item myCounter of all graphics of myDocument
								set myLink to item link of myGraphic
								if status of myLink is not normal then
									set myGraphicsCheck to false
									if SpeakTheErrors then say "[[rate " & TheSpeechRate & "]]There are linked graphics missing. " using TheVoice
									exit repeat
								end if
							end repeat