5 Replies Latest reply on Apr 3, 2008 1:39 PM by Peter Kahrel

    [JS]About image


      My name is avi.
      I want to place an image in my document. I tried all the things but i am not able to do this.
      I create a logo in Illustrator then i exported it to pdf.So i have my logo in pdf file.
      I want to place that logo in a document with the geometricBounds = ["4p8", "10p4", "6p0", "21p4"]
      I tried following script but it is not

      var myImage = new Image();
      myImage.geometricBounds = ["4p8", "10p4", "6p0", "21p4"];
      myImage = Image.place(File("~/Desktop/Master/images/LOGO.pdf"),false);

      Can anybody tell me what is wrong in above script.
      If above script do not work please tell me the other way to place the image in an document.

      I am using CS3,mac,javascript.

      Thank you
        • 1. Re: [JS]About image
          Peter Kahrel Adobe Community Professional & MVP
          You create a new image object, but you also need to use the add() method somewhere to add it to the document. But you can't add() images like that. Instead, add a rectangle (as a container for the image), then place the image in it. Something like this:

          r = app.activeDocument.pages[0].rectangles.add();
          r.geometricBounds = ["4p8", "10p4", "6p0", "21p4"];
          r.place (File ("~/Desktop/Master/images/LOGO.pdf"), false);

          • 2. Re: [JS]About image
            Level 1
            Hello peter

            when i am trying your script. i am getting a black rectangular box. I am not getting any logo on my document. In my opinion it is taking default background color as black.

            To solve this problem i tried to make second parameter of place as true
            r.place (File ("~/Desktop/Master/images/LOGO.pdf"), true);
            If you make true in place of false it will ask you option when you run the script. In that option transparent background is checked. I do not know why he is taking black as backgroung color. Please help me.

            Thank you
            • 3. Re: [JS]About image
              Peter Kahrel Adobe Community Professional & MVP
              Have a loom at the pdfPlacePreference properties. I've never used them, but it looks as if that's what you need.

              • 4. Re: [JS]About image
                Level 1
                Where should i use pdfPlacePreference. I did not get what do you want to say.
                Can you help me to write the script for this. I trying for last two day and did not come with good way to solve the problem.

                Thank you
                • 5. Re: [JS]About image
                  Peter Kahrel Adobe Community Professional & MVP
                  A bit of rummaging around in the OMV (or any equivalent) shows that pdfPlacePreferences is a property of the application. Add therefore this line to your script:

                  app.pdfPlacePreferences.transparentBackground = true;