[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(DTPtechNote:571) xmlの取り込み->PDF



XMLの取り込みからPDFまで。
ぬるい感じではあるけれど、なんとなく自動っぽい(笑)
InDesignのXMLそのものがぬるいのだけど。。。


on open of theFiles
	tell application "Finder"
		set tmplate_file to (choose file with prompt "流し込むテンプレートドキュメントを選択してください" of type {"InDd"})
		repeat with i in theFiles
			set my_folder to (folder of i) as Unicode text
			set my_name to (name of i) as Unicode text
			set save_path to my_folder & my replace(my_name, ".xml", ".indd")
			set save_PDF_path to my_folder & my replace(my_name, ".xml", ".pdf")
			my goXML(i, tmplate_file, save_path, save_PDF_path)
		end repeat
	end tell
end open

to goXML(xml_file, tmplate_file, save_path, save_PDF_path)
	tell application "InDesign 2.0.2J"
		open tmplate_file
		tell document 1
			import XML from xml_file
		end tell
		save document 1 to save_path
		export document 1 format PDF type to save_PDF_path using PDF export style "guidebook"
		close document 1
	end tell
end goXML

----------------------------------●置換
to replace(theText, orgStr, newStr)
	set oldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to orgStr
	set tmpList to every text item of theText
	set AppleScript's text item delimiters to newStr
	set tmpStr to tmpList as text
	set AppleScript's text item delimiters to oldDelim
	return tmpStr
end replace