need to make PDFs from Freehand MX files

I need to create PDFs from Freehand MX files. I found some applescript for creating EPSs but it gives me a type 2 error when I run it. I’ve also tried recording my actions but it stops recording after I open the file in Freehand. Does anyone have an applescript to do this? I’m new to Macs so any help would be greatly appreciated.

Thank you,
Chris

Hi Chris,
The script below should allow you to save your files as an EPS, then if you change the myfullpath variable to path to an Acrobat Distiller watched Folder this should hopefully do the trick!

set thefile to choose file
set myfullpath to "Macintosh HD:untitled folder:"
set file_name to "mynewfile.eps"
tell application "FreeHand MX"
	open thefile
	save document 1 in file (myfullpath & file_name) as GenericEPS
	close document 1 saving no
end tell

Hi

I’m kinda glad there getting rid of Freehand for the scripting side is complicated for no reason.
Done a bit of digging around though after struggling like hell to get a pdf.
came up with this which works, macromedia where trying to be tricky by throwing everyone of there pdf save trail in there dictionary
goodbye freehand you won’t be missed:

tell application "FreeHand MX"
	activate
	set x to name of document 1
	set myfilepath to choose folder
	set FilePath to myfilepath & x & ".pdf" as string
	save in file FilePath as "PDFWriter"
	close
end tell

don’t thank me this guy did all the hard work.

http://bbs.applescript.net/viewtopic.php?id=10506

I’m still getting a type 2 error when I run this. Does anyone know what a type 2 error means and how I can fix it? I’ve been looking online and type 2 errors seem to be caused by a variety of programs but none say how to fix it.

Here is the script I’m running

set myFolder to (choose folder "Select folder for processing:")
set myFolderList to list folder myFolder without invisibles
tell application "FreeHand MX"
	activate
	repeat with myFile in myFolderList
		open (myFolder & myFile as text)
		set FilePath to myFolder & myFile & ".pdf" as string
		save in file FilePath as "PDFWriter"
		close saving no
	end repeat
end tell

Thank you,
Chris

Hi Chris,
Give this a try, works for me!

set myFolder to (choose folder "Select folder for processing:")
tell application "Finder" to set myFolderList to every item of myFolder
repeat with myFile in myFolderList
	tell application "Finder" to set file_name to name of myFile
	tell application "FreeHand MX"
		activate
		open myFile
		save document 1 in file (myFolder & file_name) as "PDFWriter"
		close saving no
	end tell
end repeat

Ok, this is begining to work. A few problems I’m running into is that on different computers sometimes it opens a window saying that some fonts are missing. This causes the script to stop completely. I need it to select ok or hit enter if this happens so it will replace the font with another and continue running. Is this possible?

We also have freehand files that go back to freehand 5. Is there a way to open those as well? It currently doesn’t open anything older than freehand mx. It also stops when it encounters folders within the folder. I would like it to process those folders as well. Is this possible?

Thank you in advance,
Chris

this should get you through the issue of processing through nested folders and their contents

tell application "Finder" to set myFolderList to (every item of entire contents of myFolder whose kind is not "folder") as alias list

the other way to do that too would be to maybe do a whose kind or name extension is whatever freehand kicks out.

As for the scripting of the okay button and non mx version files I can’t really help… I have never even ran Freehand let alone have it to test with so I’m afraid I can’t be too much help.

Hi Chris,
you can open your Freehand files without dialogs which should stop you running into any missing font or image errors and as james suggested you can process every file inside any nested folders but as for processing any files older than MX I’m still trying to work out why the save isn’t working.

set myFolder to (choose folder "Select folder for processing:")
tell application "Finder" to set myFolderList to (every item of entire contents of myFolder whose kind is not "folder")
repeat with i from 1 to the number of items of myFolderList
	set myFile to item i of myFolderList as alias
	tell application "Finder" to set file_name to name of myFile
	tell application "FreeHand MX"
		activate
		open myFile without Dialogs
		save document 1 in file (myFolder & file_name) as "PDFWriter"
		close saving no
	end tell
end repeat

Hi Chris,
think this is what you want. There seems to be a problem with opening older versions of Freehand and saving in MX. To get around this problem I’m checking the creator and file type of each file and if it’s older than MX changing them to MX format. Once this is done you can save them as a PDF from MX, it’s a bit of a trickery on AS’s part but it seems to work. Give this a go!

set myFolder to (choose folder "Select folder for processing:")
set unrecognized_files to (myFolder as string) & "unrecognized files" --> create this folder in the top level of myFolder
set old_freehand_list to {"FH5", "FH6", "FH7", "FH8", "FH9", "FH10"}
tell application "Finder" to set myFolderList to (every item of entire contents of myFolder whose kind is not "folder")
repeat with i from 1 to the number of items of myFolderList
	set myFile to item i of myFolderList as alias
	tell application "Finder" to set file_name to name of myFile
	set file_creator to file creator of (info for myFile)
	if check_file_creator(old_freehand_list, file_creator) then
		tell application "System Events"
			set file type of myFile to "AGD6"
			set creator type of myFile to "FH11"
		end tell
		Process_Files_as_pdf(myFile, myFolder)
	else
		if file_creator = "FH11" then
			Process_Files_as_pdf(myFile, myFolder)
		else
			tell application "Finder" to move myFile to folder unrecognized_files
		end if
	end if
end repeat


on check_file_creator(old_freehand_list, file_creator)
	repeat with i from 1 to the number of items of old_freehand_list
		set creator_type to item i of old_freehand_list
		if file_creator contains creator_type then
			return true
		end if
	end repeat
	try
		set theresult to the result
	on error
		return false
	end try
end check_file_creator

on Process_Files_as_pdf(myFile, myFolder)
	tell application "Finder" to set file_name to name of myFile
	tell application "FreeHand MX"
		activate
		open myFile without Dialogs
		save document 1 in file (myFolder & file_name) as "PDFWriter"
		close saving no
	end tell
end Process_Files_as_pdf