19)PDFのページ配置

| コメント(0) | トラックバック(0)

まずAcrobatでPDFを開きページ数を数えます。そのあとでInDesignのドキュメントにPDFを1ページづつ配置していきます。さきほどのEPS配置と良く似ていますがPDFの処理が付け加えられています。

set myPer to 100
set NURI to 3 --塗り足し(0にすると塗り足しなし)
set ANS to display dialog "ドキュメントの何ページ目から配置しますか?" ¬
		default answer "1"
set inddPage to text returned of ANS
set inddPage to inddPage as integer
set pdfPage to 1
set inputFile to choose file with prompt "pdfファイルを選択"
set Fkind to kind of (info for inputFile)
if Fkind is "PDF 書類" or Fkind is "Adobe PDF document" then
	--AcrobatでPDFを開きページ数を数える
	tell application "Adobe Acrobat 7.0 Professional"
		open inputFile
		set AllPage to count page of document 1
		close document 1
	end tell
	repeat AllPage times --AllPage分繰り返す。
		set myError to my setEPS(pdfPage, inddPage, inputFile, NURI, myPer)
		set pdfPage to pdfPage + 1
		set inddPage to inddPage + 1
		if myError is "ERROR" then
			exit repeat
		end if
	end repeat
end if

--オリジナル関数setEPSの宣言
on setEPS(pdfPage, inddPage, inputFile, NURI, myPer)
	--ここより下でend tryより上を試す(エラーが出ても止まらないようにするため)
	try
		--"Adobe InDesign CS2_J"を呼ぶ
		tell application "Adobe InDesign CS2_J"
			set page number of PDF place preferences to pdfPage
			set PDF crop of PDF place preferences to crop media
			--"最前面のドキュメント"を呼ぶ
			tell active document
				--もし変数myPageのページが存在しないなら
				if not (exists of page inddPage) then
					--最後にページをつくる
					make page at end
				end if
				--ページの領域を変数myBに入れる{Y1,X1,Y2,X2}で返ってくる
				set myB to bounds of page inddPage
				--Y1より変数NURIを引いた分だけ変数Yに入れる
				set Y to (item 1 of myB) - NURI
				--X1より変数NURIを引いた分だけ変数Xに入れる
				set X to (item 2 of myB) - NURI
				--Y2よりY1を引き変数NURI*2を足した分だけ変数Hに入れる
				set H to (item 3 of myB) - (item 1 of myB) + NURI * 2
				--X2よりX1を引き変数NURI*2を足した分だけ変数Wに入れる
				set W to (item 4 of myB) - (item 2 of myB) + NURI * 2
				--"ページ"変数myPageを呼ぶ
				tell page (inddPage)
					--画像ボックスを作り変数myRectに入れる
					--(画像ボックスのプロパティは領域{Y, X, Y + H, X + W}、
					--線幅0mm、ぬりなし、線の色もなし)
					set myRect to make rectangle at beginning with properties¬
					 {geometric bounds:{Y, X, Y + H, X + W}, stroke weight:0, ¬
					fill color:"None", stroke color:"None"}
					--変数myRectの中にinputFileを配置し結果を変数EPSobjに入れる
					set PDFobj to place inputFile on myRect
					--EPSobjを呼ぶ
					tell PDFobj
						--水平方向の比率と垂直方向の比率を変数myPerにする
						set properties to {vertical scale:myPer, horizontal scale:myPer}
					end tell
					--myRectにセンター揃えの命令を送る
					fit myRect given center content
				end tell
			end tell
		end tell
		return ""
	on error
		return "ERROR"
	end try
end setEPS

トラックバック(0)

トラックバックURL: http://www.adg7.com/mt/mt-tb.cgi/99

Comments are nofollow setting

コメントする

エントリー一覧

OpenID対応しています OpenIDについて
Powered by Movable Type 7.902.0
漢字イラストロジック-脳トレ京
FREE ONLINE SUDOKU