Skip to main content
Known Participant
April 3, 2008
Question

[JS]About image

  • April 3, 2008
  • 5 replies
  • 696 views
Hello,

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
This topic has been closed for replies.

5 replies

Peter Kahrel
Community Expert
Community Expert
April 3, 2008
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;

Peter
_Avi_Author
Known Participant
April 3, 2008
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
Peter Kahrel
Community Expert
Community Expert
April 3, 2008
Have a loom at the pdfPlacePreference properties. I've never used them, but it looks as if that's what you need.

Peter
_Avi_Author
Known Participant
April 3, 2008
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
Peter Kahrel
Community Expert
Community Expert
April 3, 2008
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);

Peter