choose file: only PDF or IDd5

Below my script to open only an indesign or pdf file. But when i get the “choose file” window i can select all types of files, while its only supposed to select a file whose extention is indd or pdf. It works well without adding PDF.

set myDocument to (choose file with prompt "choose file :" of type {"IDd5", "PDF"} without invisibles)
set extention to get file type of (info for (myDocument))

if extention is "IDd5" then
	-- do something
else
	tell application "Preview"
		open myDocument
	end tell
end if

What’s going wrong?

ps:
to get the file type of any file I use this script:

get file type of (info for (choose file))

Hi,

use the type identifier instead


set myDocument to (choose file with prompt "choose file :" of type {"com.adobe.pdf", "dyn.agk8ywvdegy"} without invisibles)

StefanK, I can only select pdf files with your script. If I replace dyn.agk8ywvdegy, I create the same situation as before.