Generate Missing fonts report in Indesign

Hi All

I am trying to generate missing fonts report from indesign document. But the below code is not working, showing some errors.

Please look into it and suggest me what to do.


tell application "Adobe InDesign CS3"
	set myDoc to front document
	tell myDoc
		set Missing_Fonts to {}
		set badfontlist to (get status of every font)
		get name of every font
		repeat with This_Font in badfontlist
			if (not available is in badfontlist) or (substitute is in badfontlist) then
				set end of Missing_Fonts to name of This_Font & return
			end if
		end repeat
		set File_Path to file path as string
		set ASTID to AppleScript's text item delimiters
		set AppleScript's text item delimiters to ":"
		set Parent_Path to (text items 1 thru -2 of File_Path as string) & ":"
		set AppleScript's text item delimiters to ASTID
		if Missing_Fonts to Missing_Fonts as string then
		else
			set Missing_Fonts to "No Missing fonts..."
		end if
		my write_Report(Doc_Name, Missing_Fonts, Parent_Path)
	end tell
end tell

on write_Report(Doc_Name, Missing_Fonts, Parent_Path)
	set The_Report to Parent_Path & Doc_Name & "“Missing Fonts.txt"
	try
		open for access file the The_Report with write permission
		write Missing_Fonts to file the The_Report starting at eof
		close access file the The_Report
	on error
		close access file the The_Report
	end try
end write_Report

Thanks
Pooja

Hi Pooja,
this script incorporates what you requested in a previous post as well as this one. If any fonts are missing then it’ll collect a report and ID document in an error folder otherwise it’ll print you a PostScript file.

set source_folder to choose folder with prompt "Select folder containing Indesign Documents"
set Output_folder to choose folder with prompt "Select folder to print PostScript to"
tell application "Finder" to set item_list to every item of source_folder
repeat with this_item in item_list
	set doc_kind to kind of (info for this_item as alias)
	if doc_kind contains "Indesign" then
		tell application "Adobe InDesign CS3"
			set user interaction level of script preferences to never interact
			open this_item
			set DocName to the name of document 1
			tell document 1
				set myfontprop to properties of every font
				set font_list to {}
				repeat with i from 1 to the number of myfontprop
					set this_font_item to item i of myfontprop
					set myfontname to name of this_font_item as string
					set fontstatus to status of this_font_item as string
					set font_list to font_list & fontstatus
				end repeat
				if font_list contains "not available" then
					my error_report(Output_folder, DocName)
				else
					tell application "Adobe InDesign CS3"
						set PS_filename to characters 1 thru -6 of DocName & ".ps" as string
						set PS_Path to (Output_folder as string) & PS_filename
						set print file of printer preset "postscript" to ("" & PS_Path)
						print document 1 using "postscript" without print dialog --> needs Indesign to have a Print Preset called "postscript" that's set to print to PostScript file
						close document 1 saving no --> or yes depending on personal preference
					end tell
				end if
			end tell
		end tell
	end if
end repeat

on error_report(Output_folder, DocName)
	tell application "Finder"
		try
			set error_folder to (Output_folder as string) & DocName & "_error_folder" as alias
		on error
			tell application "Finder"
				make new folder at Output_folder with properties {name:DocName & "_error_folder"}
				set error_folder to (Output_folder as string) & DocName & "_error_folder" as alias
			end tell
		end try
	end tell
	tell application "Adobe InDesign CS3"
		tell document 1
			package to error_folder copying fonts no copying linked graphics no copying profiles no updating graphics no ignore preflight errors yes creating report yes
			close saving no
		end tell
	end tell
end error_report

Hi,
Again thanks, script is working fine, but My target folder is a Watch Folder of Distiller, so as folder is get created by script in that watch folder so Distiller is not processing next file.

Or I need another favor, Is it possible to rename the instruction.txt with the filename.txt. So that I will find out some another way to merge the documents and create a consolidate report for missing fonts.

Also one another favor. Is it possible to create error folder in the Source_folder, and the corrected file should generate PS in target_folder.

The above two will help me to process my work.

Thanks
Pooja

Hi Pooja,
This amended script should now create the error_folder in the source_folder and the “instructions.txt” will now be renamed to the original filename.txt. Let me know if you need any further help!

Nik

set source_folder to choose folder with prompt "Select folder containing Indesign Documents"
set Output_folder to choose folder with prompt "Select folder to print PostScript to"
tell application "Finder" to set item_list to every item of source_folder
repeat with this_item in item_list
	set doc_kind to kind of (info for this_item as alias)
	if doc_kind contains "Indesign" then
		tell application "Adobe InDesign CS3"
			set user interaction level of script preferences to never interact
			open this_item
			set DocName to the name of document 1
			tell document 1
				set myfontprop to properties of every font
				set font_list to {}
				repeat with i from 1 to the number of myfontprop
					set this_font_item to item i of myfontprop
					set myfontname to name of this_font_item as string
					set fontstatus to status of this_font_item as string
					set font_list to font_list & fontstatus
				end repeat
				if font_list contains "not available" then
					my error_report(source_folder, DocName)
				else
					tell application "Adobe InDesign CS3"
						set PS_filename to characters 1 thru -6 of DocName & ".ps" as string
						set PS_Path to (Output_folder as string) & PS_filename
						set print file of printer preset "postscript" to ("" & PS_Path)
						print document 1 using "postscript" without print dialog --> needs Indesign to have a Print Preset called "postscript" that's set to print to PostScript file
						close document 1 saving no --> or yes depending on personal preference
					end tell
				end if
			end tell
		end tell
	end if
end repeat

on error_report(source_folder, DocName)
	tell application "Finder"
		try
			set error_folder to (source_folder as string) & DocName & "_error_folder" as alias
		on error
			tell application "Finder"
				make new folder at source_folder with properties {name:DocName & "_error_folder"}
				set error_folder to (source_folder as string) & DocName & "_error_folder" as alias
			end tell
		end try
	end tell
	tell application "Adobe InDesign CS3"
		tell document 1
			package to error_folder copying fonts no copying linked graphics no copying profiles no updating graphics no ignore preflight errors yes creating report yes
			close saving no
		end tell
	end tell
	tell application "Finder"
		try
			set text_file to (error_folder as string) & "Instructions.txt" as alias
			set the name of text_file to DocName & ".txt"
		end try
	end tell
end error_report

Hi,

Thanks a lot, it is now working very fine. Is it possible the same thing for the QuarkXpress. I have done something for that but not able to do that.

I will develop another program to consolidate the missing fonts report.

Rgards,
Pooja

Hi,
I need to point out that if you save the script as an application then you’ll need to change this line:

				if font_list contains "not available" then

to:

				if font_list contains "«constant ****fsNA»" then

otherwise the script doesn’t work, not sure why this is but the script gets a different type of result from the script editor than it does from an application script!
With regards to Quark I’ve not scripted that before but are you trying to do the same sort of thing? What version of Quark are you using?
Nik

Hi
Thanks a lot. I am using QurakXpress 6.5. In my another post I have posted scripts for missing fonts & quark script to convert ps but it is showing error.


 if font_list contains "«constant ****fsNA»" then

It is not ligible, please copy and paste or just type as text only on the post, so that I can change in the script.

Regards,
Pooja

I know that “«constant ****fsNA»” looks weird but trust me if you replace “not available” with “«constant ****fsNA»” and save the script as an application it should work otherwise you’ll run into problems! I’ll have a look at your other posts!
Nik

Thanks a lot, I will update it as per your instruction.

Regards,
Pooja

Yes, you are right.

I have save as application and it is working fine.

Thanks again.
Pooja