Illustrator placing PDFs as images problem

Hi there,

I have got the script below:

set myFile to {alias "Pre-Media:Jobs:00001:01 Artwork:PDFs:P_Colours copy 2.pdf", alias "Pre-Media:Jobs:00001:01 Artwork:PDFs:P_Colours copy 3.pdf", alias "Pre-Media:Jobs:00001:01 Artwork:PDFs:P_Colours copy.pdf", alias "Pre-Media:Jobs:00001:01 Artwork:PDFs:P_Colours.pdf"}
set myPages to 1

PlacePDFsAsImage(myFile, myPages)


------------------------------------------------------------

on PlacePDFsAsImage(myFile, myPages)
	
	repeat with i from 1 to count of myFile
		
		set workingPDF to (item i of myFile)
		set workingPDFText to workingPDF as string
		tell application "Finder" to set FileName to name of workingPDF as text
		
		set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"_", "."}}
		set ProcessType to text item 1 of FileName
		set VersionName to text item 2 of FileName
		set Ex to last text item of FileName
		set AppleScript's text item delimiters to tids
		
		tell application "Adobe Illustrator"
			set thisDoc to current document
			tell thisDoc
				set workinglayer to make new layer with properties {name:VersionName}
			end tell
			set itemPosition to {0, 0}
			set user interaction level to never interact
			set page of PDF file options of settings to myPages
			(*set placedRef to *)
			make new placed item in layer VersionName of thisDoc with properties {file path:workingPDFText, position:itemPosition, name:VersionName}
			tell thisDoc
				move layer VersionName to end
				set visible of layer VersionName to false
			end tell
		end tell
		
	end repeat
	
end PlacePDFsAsImage

However I have a issue with the new placed item bit. It errors with the following:

Result:
error “Adobe Illustrator got an error: Unable to set placed item’s file, is the file path provided valid? Or try to use the raster item instead.” number 9080

Could somebody please help? This is part of a much bigger script I am trying to work on a bit at a time.

Thanks in advance
Andy

Something I have just discovered, if it makes a difference is if I create a new document it works OK but if I have a document with some work already on it I get the error above.

Unfortunately I want to work on an existing document.

Cheers
Andy

Can anybody help with the above please.

Cheers
Andy

Try changing this:

           make new placed item in layer VersionName of thisDoc with properties {file path:workingPDFText, position:itemPosition, name:VersionName}

to this:

           make new placed item in layer VersionName of thisDoc with properties {file path:file workingPDFText, position:itemPosition, name:VersionName}

The dictionary says file path takes a file, not a path.

Thanks for that but it still doesn’t work.

I have tried as an alias as well with no luck.

Cheers
Andy

Hi. I’m not sure if this applies to your situation and I have no way to test your specific version, but I’ve run across times where, if a link goes missing, it becomes permanently irreplaceable”by script”in AI. In CS5, file path was also read-only, which may or may not have changed.

I seam to have cracked it with the following:

make new placed item in thisDoc with properties {file path:workingPDFText, position:itemPosition, name:VersionName}

Basically not specifying the layer.

Thanks for your ideas and help.

Cheers
Andy

I’m having a very similar problem to this, with an .svg file. The code works fine for all other files, but the .svg won’t place.

I assume this then means it something specific to the contents of the file, but what might that be?

Would appreciate any ideas that I could look into.

The SVG will place fine manually, but not with applescript. Not sure why this would matter.