PDF fails to open when called from Disk Image .app

I built an Installer script for my fonts which requires a PDF of a Liceence Agreement to be opened first. Double-clicking the .app with the files in the same Folder works fine on my Hard Disk. Complete file set here…

However - double-clicking installer.app on the downloaded .dmg file that lands on the Mac OS Desktop - fails with with following error:

The is the troublesome snippet:

-- LICENCE AGREEMENT DIALOG ****** (place pdf in Disk Image) ****************
set DMChosenItems to (choose from list {"End User Licence Agreement"} with title "Licence Agreement" with prompt "Please read the Licence Agreement before continuing" OK button name "OK" cancel button name "Cancel" with multiple selections allowed)
if DMChosenItems is false then
	--script if user cancelled
	set DMBool to false
	repeat with DMItem in {"End User Licence Agreement"}
		if DMItem is in DMChosenItems then
			set DMBool to true
		end if
	end repeat
	if DMBool then
		--script if result contains desired items
		-- PDF ************************************************
		set theFile to alias ((current_path as text) & "Resources:eula.pdf")
		tell application "Finder" to open file theFile
		-- *************************************************************
		--script if disagree
	end if
	-- end if is lower
	-- END USER GUIDES DIALOG ************************************

If this script works in a Folder on the Hard Disk, why should it fail when run from Disk Image downloaded to the Desktop?

Tried for ages to solve this so any clues greatly appreciated!

If my memory is right, it would be better to code :

 set theFile to alias ((current_path as text) & "Resources:eula.pdf")
       tell application "Finder" to open  theFile


 set theFile to ((current_path as text) & "Resources:eula.pdf")
       tell application "Finder" to open file theFile

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 6 décembre 2018 21:06:59

It’s a security feature of the OS – the file has to be moved to remove the quarantine settings.

Since Apple’s introduction of Security & Privacy setting my previously working scripts have this error, even when I accept the “Open anyway” option.

Moving the file is proving impossible manually - I tried:
Downloading dmg and choosing “Save File” to the Downloads Folder.
Dragging the dmg to Hard Disk.
Make Alias of dmg on Hard Disk.

How can I script it so the User gets a seemless download and open routine?

Put a copy of the PDF inside the app bundle.

Putting a copy of the item in the app bundle sounds simple. But - I have tried to find any examples of a “bundle” and how to add items to it. All I get is fragmented bits of the puzzle and don’t know where to start. Do I need to learn the whole Applescript language to perform this?

Is there a simple example anywhere of how a bundle works: how to create a bundle, add an item (PDF), open the item?

A bundle is folder that appears as a file, with a particular arrangement on contents. Both Script Editor and Script Debugger have ways of showing you what’s in the /Contents/Resources folder of a script .app bundle, and you can add or remove files there. In SE choose View → Show Bundle Contants; in SD choose View → Resources Tab.

Once you add the item, you can use the path to resource command from Standard Additions to get its path.

I’m replying to this post a year after the fact but nevertheless, if you’re still interested in downloading pdf’s from a dmg file, I’m happy to help out. This is an area I’ve spent a fair amount of time researching due to my own software needs.If your only interest is a seamless download, the solution Shane proposes is on the spot and easy. Once you get your pdf inside a bundled script or app, as Shane proposes, the pdf stays open as long as the disk remains open. For your needs, you can easily duplicate it to the Applications folder or where you want. I would imagine, this latter solution is what you would prefer.

Unfortunately, if you’re interested in using the dmg to secure the pdf, as far I as I know, the dmg solution is less than adequate. You can keep it inside the dmg and open it for anyone to use but at that point, it’s vulnerable to unauthorized sharing because anyone can go into the open disk and copy it. The only way to cut off access to the pdf is to close the disk which can’t be done: At that point, the pdf closes along with it. This is why you occasionally see attempts to open files straight from the (unlaunched) dmg file which as far as I can see, are unsuccessful. Like this one:


If you still need help with a seamless download of your pdf, without using 3rd party software, let me know and I’m happy to help. If you’re interested in pdf security, I can show you my own solution. I use the dmg method combined with decoys and folder action scripts that I use in unique ways (that is, in ways that are different from the way they’re discussed on forums like this one).