Skip navigation
Currently Being Moderated

Embed pdf in document

Jun 20, 2012 4:45 AM

Tags: #illustrator #pdf #script

Hi all


First post and first script


Im trying to add a pdf on top of an existing PDF in illustrator using a script. This is supposed to be done by anyone at my firm so that is why I want it in a script. I also have a lot of other functions that works that will do some other stuff with this document.


Created this from the scripting guide but it doesnt work. Im pretty sure its the embedDoc var thats empty and i dont understand why.

Im not sure if the File "points" to the directory of the script or the original file but Ive tried both ofcoarse.


This is the masterpiece


var embedDoc = new File("/temp/testfile1.pdf");

if ( app.documents.length > 0 && embedDoc.exists ) {

var doc = app.activeDocument;

var placed = doc.groupItems.createFromFile( embedDoc );

}else {alert("suck")}



  • Currently Being Moderated
    Jun 20, 2012 6:26 AM   in reply to Darcus78

    I would not have thought your path was valid have you tried to just test that condition on its own?


    alert ( File("/temp/testfile1.pdf").exists );

    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 2:44 PM   in reply to Darcus78

    / always starts at the root of your current drive. What *that* means depends on your OS!


    You'd get the path from your current file by something like


    currPath = app.activeDocument.path;


    .. then you can add your temp folder with


    embedDoc = new File(currPath+'/temp/testfile.pdf");


    .. but *only* if that sub-folder actually exists in the path you stored the file in. The actual code depends entirely on your workflow, I guess.

    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 2:49 PM   in reply to Darcus78

    Are you debugging your script in the ESTK or just writing it in a text editor? What OS are you on? Where is this PDF file? ( the full path )

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points